add submission_versions table and index

This change is in anticipation of adding a more data inclusive grade
history API. Adds user_id and assignment_id to index as well.

Test Plan: n/a

refs CNVS-2802

Change-Id: Ib9f305612bbc48a6423ed955cd591d6de0658eb0
Reviewed-on: https://gerrit.instructure.com/19505
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
This commit is contained in:
Duane Johnson 2013-04-10 22:21:54 -06:00
parent 4149a41453
commit b80c03d90e
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
class AddTableSubmissionVersions < ActiveRecord::Migration
tag :predeploy
def self.up
create_table :submission_versions do |t|
t.integer "context_id", :limit => 8
t.string "context_type"
t.integer "version_id", :limit => 8
t.integer "user_id", :limit => 8
t.integer "assignment_id", :limit => 8
end
case connection.adapter_name
when 'PostgreSQL'
connection.execute(
"CREATE INDEX index_submission_versions " +
"ON submission_versions (context_id, version_id, user_id, assignment_id) " +
"WHERE context_type = 'Course'")
else
add_index :submission_versions,
[:context_id, :context_type, :version_id, :user_id, :assignment_id],
:name => 'index_submission_versions',
:unique => true
end
end
def self.down
drop_table :submission_versions
end
end