2016-02-12 23:52:43 +08:00
|
|
|
require File.expand_path('app/helpers/database_helper')
|
|
|
|
include DatabaseHelper
|
|
|
|
|
2017-06-30 16:23:28 +08:00
|
|
|
class AddOrganizationManagementSupport < ActiveRecord::Migration[4.2]
|
2016-02-12 23:52:43 +08:00
|
|
|
def up
|
2017-01-26 23:30:31 +08:00
|
|
|
# Add nullable description to team
|
|
|
|
add_column :teams, :description, :string
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
# Add estimated file size to asset (in B)
|
|
|
|
add_column :assets, :estimated_size, :integer,
|
|
|
|
default: 0
|
|
|
|
change_column_null :assets, :estimated_size, false
|
|
|
|
|
2017-01-26 23:30:31 +08:00
|
|
|
# Add space taken to team (in B!)
|
|
|
|
add_column :teams, :space_taken, :integer, limit: 5,
|
|
|
|
default: Constants::MINIMAL_TEAM_SPACE_TAKEN
|
|
|
|
change_column_null :teams, :space_taken, false
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
# Add reference to private user
|
2017-01-26 23:30:31 +08:00
|
|
|
add_column :teams, :private_user_id, :integer
|
|
|
|
add_index :teams, :private_user_id
|
|
|
|
add_foreign_key :teams, :users, column: :private_user_id
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2017-01-26 23:30:31 +08:00
|
|
|
remove_column :teams, :description
|
2016-02-12 23:52:43 +08:00
|
|
|
|
|
|
|
remove_column :assets, :estimated_size
|
|
|
|
|
2017-01-26 23:30:31 +08:00
|
|
|
remove_column :teams, :space_taken
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2017-01-26 23:30:31 +08:00
|
|
|
remove_foreign_key :teams, column: :private_user_id
|
|
|
|
remove_index :teams, :private_user_id
|
|
|
|
remove_column :teams, :private_user_id
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|
|
|
|
end
|