scinote-web/db/migrate/20161129111100_add_wopi.rb

52 lines
1.4 KiB
Ruby
Raw Normal View History

class AddWopi < ActiveRecord::Migration
2016-08-03 21:31:25 +08:00
def up
add_column :assets, :lock, :string, limit: 1024
2016-08-03 21:31:25 +08:00
add_column :assets, :lock_ttl, :integer
add_column :assets, :version, :integer, default: 1
2016-08-03 21:31:25 +08:00
create_table :wopi_discoveries do |t|
t.integer :expires, null: false
t.string :proof_key_mod, null: false
t.string :proof_key_exp, null: false
t.string :proof_key_old_mod, null: false
t.string :proof_key_old_exp, null: false
end
create_table :wopi_apps do |t|
t.string :name, null: false
t.string :icon, null: false
t.integer :wopi_discovery_id, null: false
end
create_table :wopi_actions do |t|
t.string :action, null: false
t.string :extension, null: false
t.string :urlsrc, null: false
t.integer :wopi_app_id, null: false
end
create_table :tokens do |t|
t.string :token, null: false
t.integer :ttl, null: false
t.integer :user_id, null: false
end
2016-08-03 21:31:25 +08:00
add_foreign_key :wopi_actions, :wopi_apps, column: :wopi_app_id
add_foreign_key :wopi_apps, :wopi_discoveries, column: :wopi_discovery_id
add_foreign_key :tokens, :users, column: :user_id
2016-08-03 21:31:25 +08:00
add_index :wopi_actions, [:extension, :action]
2016-08-03 21:31:25 +08:00
end
def down
remove_column :assets, :lock
remove_column :assets, :lock_ttl
remove_column :assets, :version
drop_table :wopi_actions
drop_table :wopi_apps
drop_table :wopi_discoveries
drop_table :tokens
2016-08-03 21:31:25 +08:00
end
end