1
0
Fork 0

Merge migrations

This commit is contained in:
Alex Kotov 2019-07-20 04:47:56 +05:00
parent 7d7d8fe836
commit 6e9486f99f
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 9 additions and 27 deletions

View file

@ -2,6 +2,10 @@
class DeviseCreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :accounts do |t|
t.timestamps null: false
end
create_table :users do |t|
t.timestamps null: false
@ -48,15 +52,15 @@ class DeviseCreateUsers < ActiveRecord::Migration[5.2]
t.index %i[name resource_type resource_id], unique: true
end
create_table :user_roles do |t|
create_table :account_roles do |t|
t.timestamps null: false
t.references :user, null: false
t.references :account, null: false
t.references :role, null: false
t.index %i[user_id role_id], unique: true
t.index %i[account_id role_id], unique: true
end
add_foreign_key :user_roles, :users
add_foreign_key :user_roles, :roles
add_foreign_key :account_roles, :accounts
add_foreign_key :account_roles, :roles
end
end

View file

@ -1,9 +0,0 @@
# frozen_string_literal: true
class CreateAccounts < ActiveRecord::Migration[5.2]
def change
create_table :accounts do |t|
t.timestamps null: false
end
end
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
class MoveFromUsersToAccounts < ActiveRecord::Migration[5.2]
def change
remove_foreign_key :user_roles, :users
rename_table :user_roles, :account_roles
rename_column :account_roles, :user_id, :account_id
add_foreign_key :account_roles, :accounts
end
end