Database migration

Discussion in 'Ruby' started by Jerry Jones, Feb 6, 2007.

  1. Jerry Jones

    Jerry Jones Guest

    Beginner alert.....
    I am working on a database migration. I am adding inventory items to
    the table. I have the data, but for the life of me, I cannot remember
    where to make this file. I remember how to run the migration etc.
    So where do I put the

    class AddUserTable < ActiveRecord::Migration
    def self.up
    create_table :users do |table|
    table.column :name, :string
    table.column :login, :string
    table.column :password, :string, :limit => 32
    table.column :email, :string
    end
    end

    def self.down
    drop_table :users
    end
    end
    Jerry Jones, Feb 6, 2007
    #1
    1. Advertising

  2. On 2/5/07, Jerry Jones <> wrote:
    > Beginner alert.....


    Starting at the right place will probably help: rails-users for rails,
    ruby-talk for ruby 'in general' :)

    > I am working on a database migration. I am adding inventory items to
    > the table. I have the data, but for the life of me, I cannot remember
    > where to make this file. I remember how to run the migration etc.
    > So where do I put the
    >
    > class AddUserTable < ActiveRecord::Migration
    > def self.up
    > create_table :users do |table|
    > table.column :name, :string
    > table.column :login, :string
    > table.column :password, :string, :limit => 32
    > table.column :email, :string
    > end
    > end
    >
    > def self.down
    > drop_table :users
    > end
    > end


    I'd suggest using the generator script to give you a good place to put
    your migrations - in fact, it works well for almost every file that
    you need to add. In this case:

    /script/generate migration add_user_table

    This would generate db/migrate/001_add_user_table.rb, into which you'd
    place that code that you posted.

    Dave

    --
    Dave Goodlad
    or
    http://david.goodlad.ca/
    David Goodlad, Feb 6, 2007
    #2
    1. Advertising

  3. Jerry Jones

    Mike Harris Guest

    Jerry Jones wrote:

    > Beginner alert.....
    > I am working on a database migration. I am adding inventory items to
    > the table. I have the data, but for the life of me, I cannot remember
    > where to make this file. I remember how to run the migration etc.
    > So where do I put the
    >
    > class AddUserTable < ActiveRecord::Migration
    > def self.up
    > create_table :users do |table|
    > table.column :name, :string
    > table.column :login, :string
    > table.column :password, :string, :limit => 32
    > table.column :email, :string
    > end
    > end
    >
    > def self.down
    > drop_table :users
    > end
    > end
    >
    >

    The db\migrate folder. Make a migration with ruby script\generate
    migration AddUserTable.

    Read the docs (http://api.rubyonrails.com) and please direct further
    questions to the Rails mailing list.
    Mike Harris, Feb 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roberto Herrera

    Migration problem

    Roberto Herrera, Sep 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,628
    William \(Bill\) Vaughn
    Sep 5, 2003
  2. john doe

    old database migration to java

    john doe, Feb 3, 2004, in forum: Java
    Replies:
    1
    Views:
    313
    Andrew Thompson
    Feb 3, 2004
  3. Cameron Senior

    Database to xml for data migration

    Cameron Senior, Dec 10, 2007, in forum: Ruby
    Replies:
    3
    Views:
    294
    Robert Klemme
    Dec 10, 2007
  4. Sholto Douglas
    Replies:
    0
    Views:
    444
    Sholto Douglas
    Jun 6, 2011
  5. Boni Satani
    Replies:
    0
    Views:
    158
    Boni Satani
    Jan 9, 2014
Loading...

Share This Page