Merge branch 'database' into 'master'

添加创建数据库的代码

创建数据库的代码已经完成,请求code review并合并到master

See merge request !1
This commit is contained in:
胡家煊 2016-12-07 20:19:30 +08:00
commit f97225e351
4 changed files with 60 additions and 1 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/db/schema.rb
# Ignore all logfiles and tempfiles.
/log/*

View File

@ -12,7 +12,7 @@ gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'

View File

@ -63,6 +63,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
libv8 (3.16.14.17)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
@ -104,6 +105,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (11.3.0)
rdoc (4.3.0)
ref (2.0.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
@ -124,6 +126,9 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.12)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
@ -153,6 +158,7 @@ DEPENDENCIES
sdoc (~> 0.4.0)
spring
sqlite3
therubyracer
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)

View File

@ -0,0 +1,52 @@
# 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