mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Add external_id to repository model [SCI-9977] (#6945)
This commit is contained in:
parent
254024bca8
commit
91287726c4
2 changed files with 30 additions and 6 deletions
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path('app/helpers/database_helper')
|
||||
|
||||
class CreateExternalIdColumnForRepositories < ActiveRecord::Migration[7.0]
|
||||
include DatabaseHelper
|
||||
|
||||
def up
|
||||
add_column :repositories, :external_id, :string, null: true
|
||||
add_index :repositories,
|
||||
%i(team_id external_id),
|
||||
unique: true,
|
||||
name: 'unique_index_repositories_on_external_id'
|
||||
remove_index :repository_rows, name: 'index_repository_checklist_items_on_external_id'
|
||||
remove_index :repository_rows, name: 'index_repository_list_items_on_external_id'
|
||||
remove_index :repository_rows, name: 'index_repository_rows_on_external_id'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :repositories, name: 'unique_index_repositories_on_external_id'
|
||||
remove_column :repositories, :external_id, :string, null: true
|
||||
|
||||
add_gin_index_without_tags(:repository_list_items, :external_id)
|
||||
add_gin_index_without_tags(:repository_checklist_items, :external_id)
|
||||
add_gin_index_without_tags(:repository_rows, :external_id)
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2024_01_05_162611) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2024_01_15_114821) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gist"
|
||||
enable_extension "pg_trgm"
|
||||
|
@ -621,11 +621,13 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_05_162611) do
|
|||
t.datetime "restored_on", precision: nil
|
||||
t.bigint "archived_by_id"
|
||||
t.bigint "restored_by_id"
|
||||
t.string "external_id"
|
||||
t.index ["archived"], name: "index_repositories_on_archived"
|
||||
t.index ["archived_by_id"], name: "index_repositories_on_archived_by_id"
|
||||
t.index ["discarded_at"], name: "index_repositories_on_discarded_at"
|
||||
t.index ["my_module_id"], name: "index_repositories_on_my_module_id"
|
||||
t.index ["restored_by_id"], name: "index_repositories_on_restored_by_id"
|
||||
t.index ["team_id", "external_id"], name: "unique_index_repositories_on_external_id", unique: true
|
||||
t.index ["team_id"], name: "index_repositories_on_team_id"
|
||||
end
|
||||
|
||||
|
@ -662,9 +664,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_05_162611) do
|
|||
t.datetime "updated_at", null: false
|
||||
t.string "external_id"
|
||||
t.index "trim_html_tags((data)::text) gin_trgm_ops", name: "index_repository_checklist_items_on_data", using: :gin
|
||||
t.index "trim_html_tags((external_id)::text) gin_trgm_ops", name: "index_repository_checklist_items_on_external_id", using: :gin
|
||||
t.index ["created_by_id"], name: "index_repository_checklist_items_on_created_by_id"
|
||||
t.index ["external_id"], name: "unique_index_repository_checklist_items_on_external_id", unique: true
|
||||
t.index ["last_modified_by_id"], name: "index_repository_checklist_items_on_last_modified_by_id"
|
||||
t.index ["repository_column_id", "external_id"], name: "unique_index_repository_checklist_items_on_external_id", unique: true
|
||||
t.index ["repository_column_id"], name: "index_repository_checklist_items_on_repository_column_id"
|
||||
|
@ -759,10 +759,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_05_162611) do
|
|||
t.datetime "created_at", precision: nil, null: false
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
t.string "external_id"
|
||||
t.index "trim_html_tags((external_id)::text) gin_trgm_ops", name: "index_repository_list_items_on_external_id", using: :gin
|
||||
t.index "trim_html_tags(data) gin_trgm_ops", name: "index_repository_list_items_on_data", using: :gin
|
||||
t.index ["created_by_id"], name: "index_repository_list_items_on_created_by_id"
|
||||
t.index ["external_id"], name: "unique_index_repository_list_items_on_external_id", unique: true
|
||||
t.index ["last_modified_by_id"], name: "index_repository_list_items_on_last_modified_by_id"
|
||||
t.index ["repository_column_id", "external_id"], name: "unique_index_repository_list_items_on_external_id", unique: true
|
||||
t.index ["repository_column_id"], name: "index_repository_list_items_on_repository_column_id"
|
||||
|
@ -826,7 +824,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_05_162611) do
|
|||
t.index "((id)::text) gin_trgm_ops", name: "index_repository_rows_on_id_text", using: :gin
|
||||
t.index "date_trunc('minute'::text, archived_on)", name: "index_repository_rows_on_archived_on_as_date_time_minutes"
|
||||
t.index "date_trunc('minute'::text, created_at)", name: "index_repository_rows_on_created_at_as_date_time_minutes"
|
||||
t.index "trim_html_tags((external_id)::text) gin_trgm_ops", name: "index_repository_rows_on_external_id", using: :gin
|
||||
t.index "trim_html_tags((name)::text) gin_trgm_ops", name: "index_repository_rows_on_name", using: :gin
|
||||
t.index ["archived"], name: "index_repository_rows_on_archived"
|
||||
t.index ["archived_by_id"], name: "index_repository_rows_on_archived_by_id"
|
||||
|
|
Loading…
Add table
Reference in a new issue