简体   繁体   中英

How to generate SQL Server database from schema.rb file?

I have an MS SQL Server 2012 instance with managment studio and I have schema.rb file which contains the following:

# This file is auto-generated from the current state of the database.
# Note that this schema.rb definition is the authoritative source for your database schema.

ActiveRecord::Schema.define(:version => 20120525100324) do

  create_table "academic_details", :force => true do |t|
    t.integer  "registration_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "additional_exam_groups", ["school_id"], :name => "index_additional_exam_groups_on_school_id", :limit => {"school_id"=>nil}

  create_table "additional_exam_scores", :force => true do |t|
    t.integer  "student_id"
    t.integer  "additional_exam_id"
    t.decimal  "marks",              :precision => 7, :scale => 2
    t.integer  "grading_level_id"
    t.string   "remarks"
    t.boolean  "is_failed"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "school_id"
  end.................etc.   

How to generate SQL Server database from that file?

First, is your Rails app properly configured to use MS SQL Server 2012 as its DB ?

If so, try running rake db:schema:load task.

If that doesn't work, try running the rake db:setup task.

You can find more detailed information about the rake tasks here in this previous Stackoverflow answer: https://stackoverflow.com/a/10302357/631834

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM