From 6e9486f99fea41359fd35e423270f4560d0b3ce4 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 20 Jul 2019 04:47:56 +0500 Subject: [PATCH] Merge migrations --- db/migrate/20181129203927_devise_create_users.rb | 14 +++++++++----- db/migrate/20181202020031_create_accounts.rb | 9 --------- .../20181202021854_move_from_users_to_accounts.rb | 13 ------------- 3 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 db/migrate/20181202020031_create_accounts.rb delete mode 100644 db/migrate/20181202021854_move_from_users_to_accounts.rb diff --git a/db/migrate/20181129203927_devise_create_users.rb b/db/migrate/20181129203927_devise_create_users.rb index 59944af..7933c67 100644 --- a/db/migrate/20181129203927_devise_create_users.rb +++ b/db/migrate/20181129203927_devise_create_users.rb @@ -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 diff --git a/db/migrate/20181202020031_create_accounts.rb b/db/migrate/20181202020031_create_accounts.rb deleted file mode 100644 index 7f6b1a1..0000000 --- a/db/migrate/20181202020031_create_accounts.rb +++ /dev/null @@ -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 diff --git a/db/migrate/20181202021854_move_from_users_to_accounts.rb b/db/migrate/20181202021854_move_from_users_to_accounts.rb deleted file mode 100644 index 3935421..0000000 --- a/db/migrate/20181202021854_move_from_users_to_accounts.rb +++ /dev/null @@ -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