ambition/db/migrate/20161205033804_create_table.rb

52 lines
1.3 KiB
Ruby
Raw Normal View History

2016-12-05 12:13:14 +08:00
# create tables in SQLite
# author: alan snape(alansnape@snape3058.info)
# date: 2016-12-5
class CreateTable < ActiveRecord::Migration
def change
create_table :user do |t|
t.string :name
t.string :passwd
t.string :mail
end
create_table :project do |t|
t.string :name
t.text :content
end
create_table :mission do |t|
t.string :name
t.datetime :deadline
t.integer :priority
t.string :status
end
create_table :coment do |t|
t.text :content
end
create_table :share do |t|
t.text :content
end
create_table :note do |t|
t.text :content
t.integer :user_id
end
add_foreign_key(:note, :user)
create_table :project_user, id: false do |t|
t.integer :project_id
t.integer :user_id
end
add_foreign_key(:project_user, :project)
add_foreign_key(:project_user, :user)
create_table :mission_user, id: false do |t|
t.integer :mission_id
t.integer :user_id
end
add_foreign_key(:mission_user, :mission)
add_foreign_key(:mission_user, :user)
create_table :mission_coment, id: false do |t|
t.integer :mission_id
t.integer :coment_id
end
add_foreign_key(:mission_coment, :mission)
add_foreign_key(:mission_coment, :coment)
end
end