2017-06-30 16:23:28 +08:00
|
|
|
class AddWopi < ActiveRecord::Migration[4.2]
|
2016-08-03 21:31:25 +08:00
|
|
|
def up
|
2016-09-23 17:42:12 +08:00
|
|
|
add_column :assets, :lock, :string, limit: 1024
|
2016-08-03 21:31:25 +08:00
|
|
|
add_column :assets, :lock_ttl, :integer
|
2016-08-10 23:49:25 +08:00
|
|
|
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
|
|
|
|
|
2016-11-30 23:48:42 +08:00
|
|
|
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
|
2016-11-30 23:48:42 +08:00
|
|
|
add_foreign_key :tokens, :users, column: :user_id
|
2016-08-03 21:31:25 +08:00
|
|
|
|
2016-09-23 17:42:12 +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
|
2016-11-30 23:48:42 +08:00
|
|
|
drop_table :tokens
|
2016-08-03 21:31:25 +08:00
|
|
|
end
|
|
|
|
end
|