1、迁移文件增加回滚方法

2、作品表增加所属项目字段
This commit is contained in:
sw 2015-05-21 10:54:02 +08:00
parent 86b9daf821
commit 6ac97f2c34
10 changed files with 39 additions and 8 deletions

View File

@ -30,7 +30,7 @@ class Project < ActiveRecord::Base
# Specific overidden Activities
belongs_to :homework_attach
has_many :student_works
has_many :time_entry_activities
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
has_many :memberships, :class_name => 'Member'

View File

@ -6,6 +6,7 @@ class StudentWork < ActiveRecord::Base
belongs_to :user
has_many :student_works_evaluation_distributions, :dependent => :destroy
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
acts_as_attachable
end

View File

@ -1,5 +1,5 @@
class CreateHomeworkCommons < ActiveRecord::Migration
def change
def up
create_table :homework_commons do |t|
t.string :name
t.integer :user_id
@ -13,4 +13,8 @@ class CreateHomeworkCommons < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :homework_commons
end
end

View File

@ -1,5 +1,5 @@
class CreateHomeworkDetailManuals < ActiveRecord::Migration
def change
def up
create_table :homework_detail_manuals do |t|
t.float :ta_proportion
t.integer :comment_status
@ -12,4 +12,8 @@ class CreateHomeworkDetailManuals < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :homework_detail_manuals
end
end

View File

@ -1,5 +1,5 @@
class CreateHomeworkDetailProgramings < ActiveRecord::Migration
def change
def up
create_table :homework_detail_programings do |t|
t.string :language
t.text :standard_code, :limit => 4294967295
@ -8,4 +8,8 @@ class CreateHomeworkDetailProgramings < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :homework_detail_programings
end
end

View File

@ -1,5 +1,5 @@
class CreateHomeworkTests < ActiveRecord::Migration
def change
def up
create_table :homework_tests do |t|
t.text :input
t.text :output
@ -8,4 +8,8 @@ class CreateHomeworkTests < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :homework_tests
end
end

View File

@ -1,5 +1,5 @@
class CreateStudentWorks < ActiveRecord::Migration
def change
def up
create_table :student_works do |t|
t.string :name
t.text :description
@ -9,8 +9,13 @@ class CreateStudentWorks < ActiveRecord::Migration
t.float :teacher_score, default: 0
t.float :student_score, default: 0
t.float :teaching_asistant_score, default: 0
t.integer :project_id, default: 0
t.timestamps
end
end
def down
drop_table :student_works
end
end

View File

@ -1,5 +1,5 @@
class CreateStudentWorksEvaluationDistributions < ActiveRecord::Migration
def change
def up
create_table :student_works_evaluation_distributions do |t|
t.integer :student_work_id
t.integer :user_id
@ -7,4 +7,8 @@ class CreateStudentWorksEvaluationDistributions < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :student_works_evaluation_distributions
end
end

View File

@ -1,5 +1,5 @@
class CreateStudentWorksScores < ActiveRecord::Migration
def change
def up
create_table :student_works_scores do |t|
t.integer :student_work_id
t.integer :user_id
@ -9,4 +9,8 @@ class CreateStudentWorksScores < ActiveRecord::Migration
t.timestamps
end
end
def down
drop_table :student_works_scores
end
end

View File

@ -1207,6 +1207,7 @@ ActiveRecord::Schema.define(:version => 20150519030544) do
t.float "teacher_score", :default => 0.0
t.float "student_score", :default => 0.0
t.float "teaching_asistant_score", :default => 0.0
t.integer "project_id", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end