Remove `account_authorization_configs` from old migrations
closes AE-239 flag=none test plan: - migrations run successfully on Jenkins - tests pass Change-Id: Ic89e000b89bb35f2ae20ea98b950b45e4fbe3089 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/316549 Reviewed-by: Cody Cutrer <cody@instructure.com> Migration-Review: Cody Cutrer <cody@instructure.com> QA-Review: Isaac Moore <isaac.moore@instructure.com> Product-Review: Isaac Moore <isaac.moore@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
9a34677f99
commit
42e55a6553
|
@ -90,20 +90,6 @@ class AuthenticationProvider < ActiveRecord::Base
|
|||
t("Login with %{provider}", provider: display_name)
|
||||
end
|
||||
|
||||
# Drop and recreate the authentication_providers view, if it exists.
|
||||
#
|
||||
# to be used from migrations that existed before the table rename. should
|
||||
# only be used from inside a transaction.
|
||||
def self.maybe_recreate_view
|
||||
if (view_exists = connection.view_exists?("authentication_providers"))
|
||||
connection.execute("DROP VIEW #{connection.quote_table_name("authentication_providers")}")
|
||||
end
|
||||
yield
|
||||
if view_exists
|
||||
connection.execute("CREATE VIEW #{connection.quote_table_name("authentication_providers")} AS SELECT * FROM #{connection.quote_table_name("account_authorization_configs")}")
|
||||
end
|
||||
end
|
||||
|
||||
scope :active, -> { where("workflow_state <> 'deleted'") }
|
||||
belongs_to :account
|
||||
include ::Canvas::RootAccountCacher
|
||||
|
|
|
@ -1941,7 +1941,7 @@ ActiveRecord::Relation.prepend(ExplainAnalyze)
|
|||
|
||||
# fake Rails into grabbing correct column information for a table rename in-progress
|
||||
module TableRename
|
||||
RENAMES = { "authentication_providers" => "account_authorization_configs" }.freeze
|
||||
RENAMES = {}.freeze
|
||||
|
||||
def columns(table_name)
|
||||
if (old_name = RENAMES[table_name]) && connection.table_exists?(old_name)
|
||||
|
|
|
@ -30,7 +30,7 @@ class ValidateMigrationIntegrity < ActiveRecord::Migration[4.2]
|
|||
|
||||
def self.up
|
||||
initial_migration_version = "20101210192618"
|
||||
last_squashed_migration_version = "20161229165819"
|
||||
last_squashed_migration_version = "20180425185812"
|
||||
|
||||
initial_migration_has_run = ActiveRecord::SchemaMigration.where(version: initial_migration_version).exists?
|
||||
last_squashed_migration_has_run = ActiveRecord::SchemaMigration.where(version: last_squashed_migration_version).exists?
|
|
@ -82,7 +82,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
|
|||
add_index :access_tokens, [:crypted_refresh_token], unique: true
|
||||
add_index :access_tokens, :user_id
|
||||
|
||||
create_table "account_authorization_configs", force: true do |t|
|
||||
create_table "authentication_providers", force: true do |t|
|
||||
t.integer "account_id", limit: 8, null: false
|
||||
t.integer "auth_port"
|
||||
t.string "auth_host", limit: 255
|
||||
|
@ -112,9 +112,9 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
|
|||
t.json "settings", default: {}, null: false
|
||||
end
|
||||
|
||||
add_index "account_authorization_configs", ["account_id"], name: "index_account_authorization_configs_on_account_id"
|
||||
add_index :account_authorization_configs, :workflow_state
|
||||
add_index :account_authorization_configs, :metadata_uri, where: "metadata_uri IS NOT NULL"
|
||||
add_index "authentication_providers", ["account_id"], name: "index_authentication_providers_on_account_id"
|
||||
add_index :authentication_providers, :workflow_state
|
||||
add_index :authentication_providers, :metadata_uri, where: "metadata_uri IS NOT NULL"
|
||||
|
||||
create_table "account_reports" do |t|
|
||||
t.integer "user_id", limit: 8, null: false
|
||||
|
@ -3332,7 +3332,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
|
|||
add_foreign_key :abstract_courses, :enrollment_terms
|
||||
add_foreign_key :abstract_courses, :sis_batches
|
||||
add_foreign_key :access_tokens, :users
|
||||
add_foreign_key :account_authorization_configs, :accounts
|
||||
add_foreign_key :authentication_providers, :accounts
|
||||
add_foreign_key :account_notification_roles, :account_notifications
|
||||
add_foreign_key :account_notification_roles, :roles
|
||||
add_foreign_key :account_notifications, :accounts
|
||||
|
@ -3535,7 +3535,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
|
|||
add_foreign_key :polling_poll_submissions, :users
|
||||
add_foreign_key :polling_polls, :users
|
||||
add_foreign_key :profiles, :accounts, column: "root_account_id"
|
||||
add_foreign_key :pseudonyms, :account_authorization_configs, column: :authentication_provider_id
|
||||
add_foreign_key :pseudonyms, :authentication_providers, column: :authentication_provider_id
|
||||
add_foreign_key :pseudonyms, :accounts
|
||||
add_foreign_key :pseudonyms, :sis_batches
|
||||
add_foreign_key :pseudonyms, :users
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
class FixEmptyHostedDomainForGoogle < ActiveRecord::Migration[4.2]
|
||||
tag :postdeploy
|
||||
|
||||
class AuthenticationProvider < ActiveRecord::Base
|
||||
self.table_name = "account_authorization_configs"
|
||||
end
|
||||
|
||||
def self.up
|
||||
AuthenticationProvider.where(auth_type: "google", auth_filter: "").update_all(auth_filter: nil)
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ class DefaultAuthOverTls < ActiveRecord::Migration[5.0]
|
|||
tag :predeploy
|
||||
|
||||
def change
|
||||
return if column_exists?(:account_authorization_configs, :auth_over_tls, :string, default: "start_tls")
|
||||
return if column_exists?(:authentication_providers, :auth_over_tls, :string, default: "start_tls")
|
||||
|
||||
change_column_default :account_authorization_configs, :auth_over_tls, from: nil, to: "start_tls"
|
||||
change_column_default :authentication_providers, :auth_over_tls, from: nil, to: "start_tls"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,8 +21,6 @@ class DisableNoTlsForLdap < ActiveRecord::Migration[5.0]
|
|||
tag :postdeploy
|
||||
|
||||
class AuthenticationProvider < ActiveRecord::Base
|
||||
self.table_name = "account_authorization_configs"
|
||||
|
||||
def auth_over_tls
|
||||
::AuthenticationProvider::LDAP.auth_over_tls_setting(read_attribute(:auth_over_tls))
|
||||
end
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
class CreateAuthenticationProvidersView < ActiveRecord::Migration[5.1]
|
||||
tag :predeploy
|
||||
|
||||
def up
|
||||
execute("CREATE VIEW #{connection.quote_table_name("authentication_providers")} AS SELECT * FROM #{connection.quote_table_name("account_authorization_configs")}")
|
||||
end
|
||||
|
||||
def down
|
||||
execute("DROP VIEW #{connection.quote_table_name("authentication_providers")}")
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2018 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class RenameAccountAuthorizationConfigsToAuthenticationProviders < ActiveRecord::Migration[5.1]
|
||||
tag :postdeploy
|
||||
|
||||
def up
|
||||
execute("DROP VIEW #{connection.quote_table_name("authentication_providers")}")
|
||||
rename_table :account_authorization_configs, :authentication_providers
|
||||
end
|
||||
|
||||
def down
|
||||
rename_table :authentication_providers, :account_authorization_configs
|
||||
execute("CREATE VIEW #{connection.quote_table_name("authentication_providers")} AS SELECT * FROM #{connection.quote_table_name("account_authorization_configs")}")
|
||||
end
|
||||
end
|
|
@ -21,23 +21,9 @@ class AddInternalCaFieldsToAuthenticationProvider < ActiveRecord::Migration[7.0]
|
|||
tag :predeploy
|
||||
|
||||
def change
|
||||
# `authentication_providers` was previously called `account_authorization_configs`. Before the rename occurred, a temporary
|
||||
# `authentication_providers` view was created in a predeploy migration. Then the view was dropped and the table was
|
||||
# *actually* renamed in a postdeploy migration.
|
||||
#
|
||||
# This means that if we're running all migrations at once (in a predeploy context), the frd `authentication_providers`
|
||||
# table will still be called by its old name -- so we need to identify the correct table to migrate.
|
||||
add_column :authentication_providers, :internal_ca, :text
|
||||
|
||||
if connection.table_exists?(:authentication_providers)
|
||||
add_column :authentication_providers, :internal_ca, :text
|
||||
|
||||
# this field will be removed after VERIFY_NONE is removed entirely
|
||||
add_column :authentication_providers, :verify_tls_cert_opt_in, :boolean, null: false, default: false
|
||||
else
|
||||
add_column :account_authorization_configs, :internal_ca, :text
|
||||
|
||||
# this field will be removed after VERIFY_NONE is removed entirely
|
||||
add_column :account_authorization_configs, :verify_tls_cert_opt_in, :boolean, null: false, default: false
|
||||
end
|
||||
# this field will be removed after VERIFY_NONE is removed entirely
|
||||
add_column :authentication_providers, :verify_tls_cert_opt_in, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue