# Getting an error on adding migration

**URL:** <https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686>\
**Category:** Ruby-Forum\
**Created:** [October 24, 2008, 12:37pm UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686 "2008-10-24T12:37:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@samj](https://www.ruby-forum.com/u/samj)\
**Post date:** [October 24, 2008, 12:37pm UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686/1 "2008-10-24T12:37:34Z")

</div>

Hello ,

I am a ROR beginner. I did scaffolding and made a table called  
register with a field “name”. Now when I tried to add one more column  
using add migration and then rake db:migrate, the command is executing  
successfully but new columns are not coming in the table

Sam

---

<div class="post-metadata">

**Author:** ![samj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@samj](https://www.ruby-forum.com/u/samj)\
**Post date:** [October 28, 2008, 3:25pm UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686/2 "2008-10-28T15:25:39Z")

</div>

Sam John wrote:

> Hello ,
> 
> I am a ROR beginner. I did scaffolding and made a table called  
> register with a field “name”. Now when I tried to add one more column  
> using add migration and then rake db:migrate, the command is executing  
> successfully but new columns are not coming in the table
> 
> Sam

can u plz brief a lil bit more than i am able to understand …that y ur  
columns are not coming in the table

---

<div class="post-metadata">

**Author:** ![samj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@samj](https://www.ruby-forum.com/u/samj)\
**Post date:** [October 29, 2008, 7:18am UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686/3 "2008-10-29T07:18:40Z")

</div>

Sara Criss wrote:

> Sam John wrote:
> 
> > Hello ,
> > 
> > I am a ROR beginner. I did scaffolding and made a table called  
> > register with a field “name”. Now when I tried to add one more column  
> > using add migration and then rake db:migrate, the command is executing  
> > successfully but new columns are not coming in the table
> > 
> > Sam
> 
> can u plz brief a lil bit more than i am able to understand …that y ur  
> columns are not coming in the table

Thank you for the reply 🙂 . I will explain . I did scaffolding and  
made a table called register with a field “name” . After that as I  
wanted to add more fields in that table I did the add migration command  
which is “ruby script/generate migration AddPasswordToRegister  
password:varchar” and also the rake db:migrate command. But when I run  
it on the browser the new column (password) which has been added is not  
showing there. it is only showing the “name” field which i got when i  
did scaffolding. I am able to add many columns through migration but  
they are not displaying on the browser. When I checked the files in my  
system , I could find out that new migration files are being created in  
the db/migration folder but nothing is being created in the views.

hope this would help you to understand my problem now

Sam

---

<div class="post-metadata">

**Author:** ![samj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@samj](https://www.ruby-forum.com/u/samj)\
**Post date:** [November 5, 2008, 6:19am UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686/4 "2008-11-05T06:19:16Z")

</div>

Sam Migration is to database and Scaffold is for view purpose.

On running migration a column may be added to yr DB. Check that first if  
there is a column the work of migration is that and its done.

Scaffold is responsible to generate CRUD skeleton code. Since you did  
scaffold before adding the new field password thats not reflected.

Cheers,  
Ratnvael.

---

<div class="post-metadata">

**Author:** ![samj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@samj](https://www.ruby-forum.com/u/samj)\
**Post date:** [February 19, 2016, 8:49am UTC](https://www.ruby-forum.com/t/getting-an-error-on-adding-migration/151686/5 "2016-02-19T08:49:21Z")

</div>

Enabling Migrations

It’s time to make some more changes to our model.

Let’s introduce a Url property to the Blog class.  
public class Blog  
{  
public int BlogId { get; set; }  
public string Name { get; set; }  
public string Url { get; set; }  
}  
If you were to run the application again you would get an  
InvalidOperationException because the database no longer matches your  
model.

”The model backing the ‘BlogContext’ context has changed since the  
database was created. Consider using Code First Migrations to update the  
database ([Code First Migrations - EF6 | Microsoft Learn](http://go.microsoft.com/fwlink/?LinkId=238269)).”  
.  
As the exception suggests, it’s time to start using Code First  
Migrations. The first step is to enable migrations for our context.  
Run the ‘Enable-Migrations’ command in Package Manager Console.  
. .  
This command has added a Migrations folder to our project. This new  
folder contains two files:  
The Configuration class. This class allows you to configure how  
Migrations behaves for your context. For this walkthrough we will just  
use the default configuration.  
Because there is just a single Code First context in your project,  
Enable-Migrations has automatically filled in the context type that this  
configuration applies to.  
An InitialCreate migration. This migration was generated because we  
already had Code First create a database for us, before we enabled  
migrations. The code in this scaffolded migration represents the objects  
that have already been created in the database. In our case that is the  
Blog table with a BlogId and Name columns.  
[Primavera Training in Chennai | Best Primavera Training Institutes in Chennai](http://www.traininginsholinganallur.in/primavera-training-in-chennai.html)  
[Big Data Analytics Training in Chennai, sholinganallur | Best Big Data Training in OMR, Chennai](http://www.traininginsholinganallur.in/big-data-analytics-training-in-chennai.html)
