【发布时间】:2014-11-28 05:42:17
【问题描述】:
我已经创建了数据建模并导入了 sql 文件并为我的所有模型生成了架构,如下所示。现在我想在没有迁移文件的情况下为 MySQl 中的所有表生成模型。
另外,我有两个名称范围,并且希望对具有不同名称范围的所有控制器使用相同的模型。
# Create a new Rails Project
rails new <project-name> -d mysql
# Run Bundler
bundle install
# Database Initiation
rake db:create
# Dump SQL file into MySQL
mysql -u hmv -p <database-name> < <database-file>
# Generate SQL Schema from the MySQL tables
rake db:schema:dump
# Creating a Git Repo for Versioning and Collaboration
git init
git remote add origin https://<Username>:<Password>@bitbucket.org/harshamv/<Project-Name>.git
git add .
git commit -m 'Initial commit'
git push -u origin master
# Create the Initial Migration File
rails generate migration initial_schema_dump
# Copy the Content from the Schema file to the migration file and run the following command
rake db:migrate
【问题讨论】:
标签: mysql ruby-on-rails ruby-on-rails-4