Forum: Ruby-Forum.com Getting an error on adding migration

45a7599d67c3819a0023f0f5f15d77ca?d=identicon&s=25 Sam John (sumin)
on 2008-10-24 12:37
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
C19de50a99c0b4d7671bb85ce49b08d3?d=identicon&s=25 Sara Criss (sara_criss)
on 2008-10-28 15:25
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
45a7599d67c3819a0023f0f5f15d77ca?d=identicon&s=25 Sam John (sumin)
on 2008-10-29 07:18
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
D21058138cd06ffa74c9a386c358feab?d=identicon&s=25 Ratnavel P S (ratnavel)
on 2008-11-05 06:19
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.
747281435101a4fde9b1c392ad16ec94?d=identicon&s=25 Jack Vincent (jackvincent)
on 2016-02-19 08:49
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 (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.
http://www.traininginsholinganallur.in/primavera-t...
http://www.traininginsholinganallur.in/big-data-an...
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.