fix migration
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class PopulateSubmitterAccountId < ActiveRecord::Migration[7.1]
|
class PopulateSubmitterAccountId < ActiveRecord::Migration[7.1]
|
||||||
disable_ddl_transaction
|
disable_ddl_transaction!
|
||||||
|
|
||||||
class MigrationSubmitter < ApplicationRecord
|
class MigrationSubmitter < ApplicationRecord
|
||||||
self.table_name = 'submitters'
|
self.table_name = 'submitters'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class PopulateCompletedSubmittersAndDocuments < ActiveRecord::Migration[7.2]
|
class PopulateCompletedSubmittersAndDocuments < ActiveRecord::Migration[7.2]
|
||||||
disable_ddl_transaction
|
disable_ddl_transaction!
|
||||||
|
|
||||||
class MigrationSubmitter < ApplicationRecord
|
class MigrationSubmitter < ApplicationRecord
|
||||||
self.table_name = 'submitters'
|
self.table_name = 'submitters'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class PopulateWebhookUrls < ActiveRecord::Migration[7.2]
|
class PopulateWebhookUrls < ActiveRecord::Migration[7.2]
|
||||||
disable_ddl_transaction
|
disable_ddl_transaction!
|
||||||
|
|
||||||
class MigrationWebhookUrl < ActiveRecord::Base
|
class MigrationWebhookUrl < ActiveRecord::Base
|
||||||
self.table_name = 'webhook_urls'
|
self.table_name = 'webhook_urls'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AddSharedLinkToTemplates < ActiveRecord::Migration[8.0]
|
class AddSharedLinkToTemplates < ActiveRecord::Migration[8.0]
|
||||||
disable_ddl_transaction
|
disable_ddl_transaction!
|
||||||
|
|
||||||
class MigrationTemplate < ActiveRecord::Base
|
class MigrationTemplate < ActiveRecord::Base
|
||||||
self.table_name = 'templates'
|
self.table_name = 'templates'
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateSearchEnties < ActiveRecord::Migration[8.0]
|
class CreateSearchEnties < ActiveRecord::Migration[8.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def up
|
def up
|
||||||
return unless adapter_name == 'PostgreSQL'
|
return unless adapter_name == 'PostgreSQL'
|
||||||
|
|
||||||
enable_extension 'btree_gin'
|
|
||||||
|
|
||||||
create_table :search_entries do |t|
|
create_table :search_entries do |t|
|
||||||
t.references :record, null: false, polymorphic: true, index: false
|
t.references :record, null: false, polymorphic: true, index: false
|
||||||
t.bigint :account_id, null: false
|
t.bigint :account_id, null: false
|
||||||
@@ -14,12 +14,24 @@ class CreateSearchEnties < ActiveRecord::Migration[8.0]
|
|||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Submitter'",
|
begin
|
||||||
name: 'index_search_entries_on_account_id_tsvector_submitter'
|
enable_extension 'btree_gin'
|
||||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Submission'",
|
rescue StandardError
|
||||||
name: 'index_search_entries_on_account_id_tsvector_submission'
|
nil
|
||||||
add_index :search_entries, %i[account_id tsvector], using: :gin, where: "record_type = 'Template'",
|
end
|
||||||
name: 'index_search_entries_on_account_id_tsvector_template'
|
|
||||||
|
btree_gin_enabled = extension_enabled?('btree_gin')
|
||||||
|
|
||||||
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
|
using: :gin, where: "record_type = 'Submitter'",
|
||||||
|
name: 'index_search_entries_on_account_id_tsvector_submitter'
|
||||||
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
|
using: :gin, where: "record_type = 'Submission'",
|
||||||
|
name: 'index_search_entries_on_account_id_tsvector_submission'
|
||||||
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
|
using: :gin, where: "record_type = 'Template'",
|
||||||
|
name: 'index_search_entries_on_account_id_tsvector_template'
|
||||||
|
|
||||||
add_index :search_entries, %i[record_id record_type], unique: true
|
add_index :search_entries, %i[record_id record_type], unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,6 +40,10 @@ class CreateSearchEnties < ActiveRecord::Migration[8.0]
|
|||||||
|
|
||||||
drop_table :search_entries
|
drop_table :search_entries
|
||||||
|
|
||||||
disable_extension 'btree_gin'
|
begin
|
||||||
|
disable_extension 'btree_gin'
|
||||||
|
rescue StandardError
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ class AddNgramToSearchIndex < ActiveRecord::Migration[8.0]
|
|||||||
def change
|
def change
|
||||||
return unless adapter_name == 'PostgreSQL'
|
return unless adapter_name == 'PostgreSQL'
|
||||||
|
|
||||||
|
btree_gin_enabled = extension_enabled?('btree_gin')
|
||||||
|
|
||||||
add_column :search_entries, :ngram, :tsvector
|
add_column :search_entries, :ngram, :tsvector
|
||||||
|
|
||||||
add_index :search_entries, %i[account_id ngram], using: :gin, where: "record_type = 'Submitter'",
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
name: 'index_search_entries_on_account_id_ngram_submitter'
|
using: :gin, where: "record_type = 'Submitter'",
|
||||||
add_index :search_entries, %i[account_id ngram], using: :gin, where: "record_type = 'Submission'",
|
name: 'index_search_entries_on_account_id_ngram_submitter'
|
||||||
name: 'index_search_entries_on_account_id_ngram_submission'
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
add_index :search_entries, %i[account_id ngram], using: :gin, where: "record_type = 'Template'",
|
using: :gin, where: "record_type = 'Submission'",
|
||||||
name: 'index_search_entries_on_account_id_ngram_template'
|
name: 'index_search_entries_on_account_id_ngram_submission'
|
||||||
|
add_index :search_entries, btree_gin_enabled ? %i[account_id tsvector] : :tsvector,
|
||||||
|
using: :gin, where: "record_type = 'Template'",
|
||||||
|
name: 'index_search_entries_on_account_id_ngram_template'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user