From 3ecf4bbbc40a1764b5ecfbf145afcccb378b1d7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:05:31 +0000 Subject: [PATCH 1/3] Initial plan From 04e3abbed7692d7b8d9a8b1c87cd71a92c5032b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:19:55 +0000 Subject: [PATCH 2/3] Fix root node siblings not reordered after prepend_child/add_sibling moves a root to child position Co-authored-by: seuros <2394703+seuros@users.noreply.github.com> --- .../numeric_deterministic_ordering.rb | 15 +- test/closure_tree/label_order_value_test.rb | 65 +++ test/dummy/db/lite_schema.rb | 14 + test/dummy/db/schema.rb | 509 ++++++++++-------- test/dummy/db/secondary_schema.rb | 56 +- 5 files changed, 388 insertions(+), 271 deletions(-) create mode 100644 test/dummy/db/lite_schema.rb diff --git a/lib/closure_tree/numeric_deterministic_ordering.rb b/lib/closure_tree/numeric_deterministic_ordering.rb index ab49f321..95f4146d 100644 --- a/lib/closure_tree/numeric_deterministic_ordering.rb +++ b/lib/closure_tree/numeric_deterministic_ordering.rb @@ -30,6 +30,15 @@ def _ct_reorder_children(minimum_sort_order_value = nil) _ct.reorder_with_parent_id(_ct_id, minimum_sort_order_value, scope_conditions) end + def _ct_reorder_prior_parent_or_roots(prior_parent, was_root) + if prior_parent + prior_parent._ct_reorder_children + elsif was_root && !_ct.dont_order_roots + scope_conditions = _ct.scope_values_from_instance(self) + _ct.reorder_with_parent_id(nil, nil, scope_conditions) + end + end + def self_and_descendants_preordered # TODO: raise NotImplementedError if sort_order is not numeric and not null? hierarchy_table = self.class.hierarchy_class.arel_table @@ -130,11 +139,14 @@ def append_child(child_node) end def prepend_child(child_node) + prior_parent = child_node.parent + was_root = prior_parent.nil? && child_node.persisted? child_node.order_value = -1 child_node.parent = self child_node._ct_skip_sort_order_maintenance! if child_node.save _ct_reorder_children + _ct_reorder_prior_parent_or_roots(prior_parent, was_root) child_node.reload else child_node @@ -161,6 +173,7 @@ def add_sibling(sibling, add_after = true) _ct.with_advisory_lock do prior_sibling_parent = sibling.parent + sibling_was_root = prior_sibling_parent.nil? && sibling.persisted? reorder_from_value = if prior_sibling_parent == parent [order_value, sibling.order_value].compact.min else @@ -184,7 +197,7 @@ def add_sibling(sibling, add_after = true) sibling.update_order_value(self_ov) end - prior_sibling_parent.try(:_ct_reorder_children) if prior_sibling_parent != parent + sibling._ct_reorder_prior_parent_or_roots(prior_sibling_parent, sibling_was_root) if prior_sibling_parent != parent sibling end end diff --git a/test/closure_tree/label_order_value_test.rb b/test/closure_tree/label_order_value_test.rb index 968a3323..ac286d4c 100644 --- a/test/closure_tree/label_order_value_test.rb +++ b/test/closure_tree/label_order_value_test.rb @@ -53,4 +53,69 @@ def setup assert_equal 1, b.order_value assert_equal 2, c.order_value end + + test 'should reorder remaining root nodes when a root node becomes a child via prepend_child' do + node_1 = Label.create(name: 'node_1') + node_2 = Label.create(name: 'node_2') + node_3 = Label.create(name: 'node_3') + node_4 = Label.create(name: 'node_4') + + # Verify initial positions + assert_equal 0, node_1.order_value + assert_equal 1, node_2.order_value + assert_equal 2, node_3.order_value + assert_equal 3, node_4.order_value + + # Move node_2 as a child of node_3 using prepend_child + node_3.prepend_child(node_2) + + # Reload all nodes to get updated positions + node_1.reload + node_2.reload + node_3.reload + node_4.reload + + # Verify node_2 is now a child of node_3 with position 0 + assert_equal node_3.id, node_2._ct_parent_id + assert_equal 0, node_2.order_value + + # Verify remaining root nodes have sequential positions without gaps + assert_equal 0, node_1.order_value + assert_equal 1, node_3.order_value + assert_equal 2, node_4.order_value + end + + test 'should reorder remaining root nodes when a root node becomes a child via add_sibling' do + node_1 = Label.create(name: 'node_1') + node_2 = Label.create(name: 'node_2') + node_3 = Label.create(name: 'node_3') + node_4 = Label.create(name: 'node_4') + + # Create a child under node_3 + child = Label.create(name: 'child', parent: node_3) + + # Verify initial positions + assert_equal 0, node_1.order_value + assert_equal 1, node_2.order_value + assert_equal 2, node_3.order_value + assert_equal 3, node_4.order_value + assert_equal 0, child.order_value + + # Move node_2 as a sibling of child (making it a child of node_3) + child.add_sibling(node_2) + + # Reload all nodes to get updated positions + node_1.reload + node_2.reload + node_3.reload + node_4.reload + + # Verify node_2 is now a child of node_3 + assert_equal node_3.id, node_2._ct_parent_id + + # Verify remaining root nodes have sequential positions without gaps + assert_equal 0, node_1.order_value + assert_equal 1, node_3.order_value + assert_equal 2, node_4.order_value + end end diff --git a/test/dummy/db/lite_schema.rb b/test/dummy/db/lite_schema.rb new file mode 100644 index 00000000..03e73681 --- /dev/null +++ b/test/dummy/db/lite_schema.rb @@ -0,0 +1,14 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[8.1].define(version: 0) do +end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 0602b1f3..5e8b4cc6 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -1,271 +1,302 @@ -# frozen_string_literal: true +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 1) do - create_table 'tags' do |t| - t.string 'name' - t.string 'title' - t.references 'parent' - t.integer 'sort_order' - t.timestamps null: false +ActiveRecord::Schema[8.1].define(version: 1) do + # These are extensions that must be enabled in order to support this database + enable_extension "pg_catalog.plpgsql" + + create_table "adoptable_tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "adoptable_tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_adoptable_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "adoptable_tag_desc_idx" + t.index ["descendant_id"], name: "index_adoptable_tag_hierarchies_on_descendant_id" end - create_table 'tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false + create_table "adoptable_tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_adoptable_tags_on_parent_id" end - create_table 'uuid_tags', id: false do |t| - t.string 'uuid', primary_key: true - t.string 'name' - t.string 'title' - t.string 'parent_uuid' - t.integer 'sort_order' - t.timestamps null: false + create_table "contract_types", force: :cascade do |t| + t.string "name", null: false end - create_table 'uuid_tag_hierarchies', id: false do |t| - t.string 'ancestor_id', null: false - t.string 'descendant_id', null: false - t.integer 'generations', null: false + create_table "contracts", force: :cascade do |t| + t.bigint "contract_type_id" + t.string "title" + t.bigint "user_id", null: false + t.index ["contract_type_id"], name: "index_contracts_on_contract_type_id" + t.index ["user_id"], name: "index_contracts_on_user_id" end - create_table 'destroyed_tags' do |t| - t.string 'name' + create_table "cuisine_type_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id"], name: "index_cuisine_type_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_cuisine_type_hierarchies_on_descendant_id" end - add_index 'tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'tag_anc_desc_idx' - add_index 'tag_hierarchies', [:descendant_id], name: 'tag_desc_idx' - - create_table 'groups' do |t| - t.string 'name', null: false - end - - create_table 'groupings' do |t| - t.string 'name', null: false - end - - create_table 'user_sets' do |t| - t.string 'name', null: false - end - - create_table 'teams' do |t| - t.string 'name', null: false + create_table "cuisine_types", force: :cascade do |t| + t.string "name" + t.bigint "parent_id" + t.index ["parent_id"], name: "index_cuisine_types_on_parent_id" end - create_table 'users' do |t| - t.string 'email' - t.references 'referrer' - t.integer 'group_id' - t.timestamps null: false + create_table "destroyed_tags", force: :cascade do |t| + t.string "name" end - - create_table 'contracts' do |t| - t.references 'user', null: false - t.references 'contract_type' - t.string 'title' - end - - create_table 'contract_types' do |t| - t.string 'name', null: false + + create_table "groupings", force: :cascade do |t| + t.string "name", null: false end - create_table 'referral_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false + create_table "groups", force: :cascade do |t| + t.string "name", null: false end - create_table 'labels' do |t| - t.string 'name' - t.string 'type' - t.integer 'column_whereby_ordering_is_inferred' - t.references 'mother' - end + create_table "label_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "lh_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_label_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_label_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "lh_desc_idx" + end - create_table 'label_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false + create_table "labels", force: :cascade do |t| + t.integer "column_whereby_ordering_is_inferred" + t.bigint "mother_id" + t.string "name" + t.string "type" + t.index ["mother_id"], name: "index_labels_on_mother_id" + end + + create_table "lite_tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "lite_tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_lite_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_lite_tag_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "lite_tag_desc_idx" + end + + create_table "lite_tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_lite_tags_on_parent_id" end - create_table 'cuisine_types' do |t| - t.string 'name' - t.references 'parent' + create_table "memory_adoptable_tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "memory_adoptable_tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_memory_adoptable_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_memory_adoptable_tag_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "memory_adoptable_tag_desc_idx" end - create_table 'cuisine_type_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false + create_table "memory_adoptable_tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_memory_adoptable_tags_on_parent_id" end - create_table 'namespace_types' do |t| - t.string 'name' - t.references 'parent' + create_table "menu_item_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id"], name: "index_menu_item_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_menu_item_hierarchies_on_descendant_id" end - create_table 'namespace_type_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - # PostgreSQL schema-qualified tables - execute "CREATE SCHEMA IF NOT EXISTS test_schema" - - create_table 'test_schema.schema_types', force: true do |t| - t.string 'name' - t.references 'parent' - end - - create_table 'test_schema.schema_type_hierarchies', id: false, force: true do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - create_table 'metal' do |t| - t.references 'parent' - t.string 'metal_type' - t.string 'value' - t.string 'description' - t.integer 'sort_order' - end - - create_table 'metal_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - create_table 'menu_items' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false - end - - create_table 'menu_item_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'label_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'lh_anc_desc_idx' - add_index 'label_hierarchies', [:descendant_id], name: 'lh_desc_idx' - add_index 'referral_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'ref_anc_desc_idx' - add_index 'referral_hierarchies', [:descendant_id], name: 'ref_desc_idx' - - add_foreign_key(:tags, :tags, column: 'parent_id', on_delete: :cascade) - add_foreign_key(:users, :users, column: 'referrer_id', on_delete: :cascade) - add_foreign_key(:labels, :labels, column: 'mother_id', on_delete: :cascade) - add_foreign_key(:metal, :metal, column: 'parent_id', on_delete: :cascade) - add_foreign_key(:menu_items, :menu_items, column: 'parent_id', on_delete: :cascade) - add_foreign_key(:menu_item_hierarchies, :menu_items, column: 'ancestor_id', on_delete: :cascade) - add_foreign_key(:menu_item_hierarchies, :menu_items, column: 'descendant_id', on_delete: :cascade) - add_foreign_key(:tag_hierarchies, :tags, column: 'ancestor_id', on_delete: :cascade) - add_foreign_key(:tag_hierarchies, :tags, column: 'descendant_id', on_delete: :cascade) - - # Multi-database test models - create_table 'secondary_tags' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false - end - - create_table 'secondary_tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'secondary_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'secondary_tag_anc_desc_idx' - add_index 'secondary_tag_hierarchies', [:descendant_id], name: 'secondary_tag_desc_idx' - - create_table 'lite_tags' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false - end - - create_table 'lite_tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'lite_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'lite_tag_anc_desc_idx' - add_index 'lite_tag_hierarchies', [:descendant_id], name: 'lite_tag_desc_idx' - - create_table 'scoped_items' do |t| - t.string 'name' - t.references 'parent' - t.integer 'sort_order' - t.integer 'user_id' - t.integer 'group_id' - t.timestamps null: false - end - - create_table 'scoped_item_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'scoped_item_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'scoped_item_anc_desc_idx' - add_index 'scoped_item_hierarchies', [:descendant_id], name: 'scoped_item_desc_idx' - - create_table 'adoptable_tags' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false - end - - create_table 'adoptable_tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'adoptable_tag_anc_desc_idx' - add_index 'adoptable_tag_hierarchies', [:descendant_id], name: 'adoptable_tag_desc_idx' - - create_table 'secondary_adoptable_tags' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false - end - - create_table 'secondary_adoptable_tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false - end - - add_index 'secondary_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'secondary_adoptable_tag_anc_desc_idx' - add_index 'secondary_adoptable_tag_hierarchies', [:descendant_id], name: 'secondary_adoptable_tag_desc_idx' - - create_table 'memory_adoptable_tags' do |t| - t.string 'name' - t.references 'parent' - t.timestamps null: false + create_table "menu_items", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_menu_items_on_parent_id" end - create_table 'memory_adoptable_tag_hierarchies', id: false do |t| - t.references 'ancestor', null: false - t.references 'descendant', null: false - t.integer 'generations', null: false + create_table "metal", force: :cascade do |t| + t.string "description" + t.string "metal_type" + t.bigint "parent_id" + t.integer "sort_order" + t.string "value" + t.index ["parent_id"], name: "index_metal_on_parent_id" end - add_index 'memory_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'memory_adoptable_tag_anc_desc_idx' - add_index 'memory_adoptable_tag_hierarchies', [:descendant_id], name: 'memory_adoptable_tag_desc_idx' + create_table "metal_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id"], name: "index_metal_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_metal_hierarchies_on_descendant_id" + end + + create_table "namespace_type_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id"], name: "index_namespace_type_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_namespace_type_hierarchies_on_descendant_id" + end + + create_table "namespace_types", force: :cascade do |t| + t.string "name" + t.bigint "parent_id" + t.index ["parent_id"], name: "index_namespace_types_on_parent_id" + end + + create_table "referral_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "ref_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_referral_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_referral_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "ref_desc_idx" + end + + create_table "scoped_item_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "scoped_item_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_scoped_item_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_scoped_item_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "scoped_item_desc_idx" + end + + create_table "scoped_items", force: :cascade do |t| + t.datetime "created_at", null: false + t.integer "group_id" + t.string "name" + t.bigint "parent_id" + t.integer "sort_order" + t.datetime "updated_at", null: false + t.integer "user_id" + t.index ["parent_id"], name: "index_scoped_items_on_parent_id" + end + + create_table "secondary_adoptable_tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_adoptable_tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_secondary_adoptable_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_secondary_adoptable_tag_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "secondary_adoptable_tag_desc_idx" + end + + create_table "secondary_adoptable_tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_secondary_adoptable_tags_on_parent_id" + end + + create_table "secondary_tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_secondary_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_secondary_tag_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "secondary_tag_desc_idx" + end + + create_table "secondary_tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_secondary_tags_on_parent_id" + end + + create_table "tag_hierarchies", id: false, force: :cascade do |t| + t.bigint "ancestor_id", null: false + t.bigint "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "tag_anc_desc_idx", unique: true + t.index ["ancestor_id"], name: "index_tag_hierarchies_on_ancestor_id" + t.index ["descendant_id"], name: "index_tag_hierarchies_on_descendant_id" + t.index ["descendant_id"], name: "tag_desc_idx" + end + + create_table "tags", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.bigint "parent_id" + t.integer "sort_order" + t.string "title" + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_tags_on_parent_id" + end + + create_table "teams", force: :cascade do |t| + t.string "name", null: false + end + + create_table "user_sets", force: :cascade do |t| + t.string "name", null: false + end + + create_table "users", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "email" + t.integer "group_id" + t.bigint "referrer_id" + t.datetime "updated_at", null: false + t.index ["referrer_id"], name: "index_users_on_referrer_id" + end + + create_table "uuid_tag_hierarchies", id: false, force: :cascade do |t| + t.string "ancestor_id", null: false + t.string "descendant_id", null: false + t.integer "generations", null: false + end + + create_table "uuid_tags", primary_key: "uuid", id: :string, force: :cascade do |t| + t.datetime "created_at", null: false + t.string "name" + t.string "parent_uuid" + t.integer "sort_order" + t.string "title" + t.datetime "updated_at", null: false + end + + add_foreign_key "labels", "labels", column: "mother_id", on_delete: :cascade + add_foreign_key "menu_item_hierarchies", "menu_items", column: "ancestor_id", on_delete: :cascade + add_foreign_key "menu_item_hierarchies", "menu_items", column: "descendant_id", on_delete: :cascade + add_foreign_key "menu_items", "menu_items", column: "parent_id", on_delete: :cascade + add_foreign_key "metal", "metal", column: "parent_id", on_delete: :cascade + add_foreign_key "tag_hierarchies", "tags", column: "ancestor_id", on_delete: :cascade + add_foreign_key "tag_hierarchies", "tags", column: "descendant_id", on_delete: :cascade + add_foreign_key "tags", "tags", column: "parent_id", on_delete: :cascade + add_foreign_key "users", "users", column: "referrer_id", on_delete: :cascade end diff --git a/test/dummy/db/secondary_schema.rb b/test/dummy/db/secondary_schema.rb index f35d629f..09454804 100644 --- a/test/dummy/db/secondary_schema.rb +++ b/test/dummy/db/secondary_schema.rb @@ -1,49 +1,43 @@ -# frozen_string_literal: true - # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do - create_table 'secondary_tags', force: true do |t| - t.string 'name' - t.integer 'parent_id' - t.datetime 'created_at' - t.datetime 'updated_at' +ActiveRecord::Schema[8.1].define(version: 0) do + create_table "secondary_adoptable_tag_hierarchies", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.integer "ancestor_id", null: false + t.integer "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_adoptable_tag_anc_desc_idx", unique: true + t.index ["descendant_id"], name: "secondary_adoptable_tag_desc_idx" end - create_table 'secondary_tag_hierarchies', id: false, force: true do |t| - t.integer 'ancestor_id', null: false - t.integer 'descendant_id', null: false - t.integer 'generations', null: false + create_table "secondary_adoptable_tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at" + t.string "name" + t.integer "parent_id" + t.datetime "updated_at" end - add_index 'secondary_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'secondary_tag_anc_des_idx' - add_index 'secondary_tag_hierarchies', [:descendant_id], name: 'secondary_tag_desc_idx' - - create_table 'secondary_adoptable_tags', force: true do |t| - t.string 'name' - t.integer 'parent_id' - t.datetime 'created_at' - t.datetime 'updated_at' + create_table "secondary_tag_hierarchies", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.integer "ancestor_id", null: false + t.integer "descendant_id", null: false + t.integer "generations", null: false + t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_tag_anc_des_idx", unique: true + t.index ["descendant_id"], name: "secondary_tag_desc_idx" end - create_table 'secondary_adoptable_tag_hierarchies', id: false, force: true do |t| - t.integer 'ancestor_id', null: false - t.integer 'descendant_id', null: false - t.integer 'generations', null: false + create_table "secondary_tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at" + t.string "name" + t.integer "parent_id" + t.datetime "updated_at" end - - add_index 'secondary_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, - name: 'secondary_adoptable_tag_anc_desc_idx' - add_index 'secondary_adoptable_tag_hierarchies', [:descendant_id], name: 'secondary_adoptable_tag_desc_idx' end From 8dfac7c5713183d0e1a693a2a76ca8a0843e1f58 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:20:28 +0000 Subject: [PATCH 3/3] Restore original schema files Co-authored-by: seuros <2394703+seuros@users.noreply.github.com> --- test/dummy/db/lite_schema.rb | 14 - test/dummy/db/schema.rb | 509 ++++++++++++++---------------- test/dummy/db/secondary_schema.rb | 56 ++-- 3 files changed, 270 insertions(+), 309 deletions(-) delete mode 100644 test/dummy/db/lite_schema.rb diff --git a/test/dummy/db/lite_schema.rb b/test/dummy/db/lite_schema.rb deleted file mode 100644 index 03e73681..00000000 --- a/test/dummy/db/lite_schema.rb +++ /dev/null @@ -1,14 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[8.1].define(version: 0) do -end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 5e8b4cc6..0602b1f3 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -1,302 +1,271 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. +# frozen_string_literal: true -ActiveRecord::Schema[8.1].define(version: 1) do - # These are extensions that must be enabled in order to support this database - enable_extension "pg_catalog.plpgsql" - - create_table "adoptable_tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "adoptable_tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_adoptable_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "adoptable_tag_desc_idx" - t.index ["descendant_id"], name: "index_adoptable_tag_hierarchies_on_descendant_id" +ActiveRecord::Schema.define(version: 1) do + create_table 'tags' do |t| + t.string 'name' + t.string 'title' + t.references 'parent' + t.integer 'sort_order' + t.timestamps null: false end - create_table "adoptable_tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_adoptable_tags_on_parent_id" + create_table 'tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false end - create_table "contract_types", force: :cascade do |t| - t.string "name", null: false + create_table 'uuid_tags', id: false do |t| + t.string 'uuid', primary_key: true + t.string 'name' + t.string 'title' + t.string 'parent_uuid' + t.integer 'sort_order' + t.timestamps null: false end - create_table "contracts", force: :cascade do |t| - t.bigint "contract_type_id" - t.string "title" - t.bigint "user_id", null: false - t.index ["contract_type_id"], name: "index_contracts_on_contract_type_id" - t.index ["user_id"], name: "index_contracts_on_user_id" + create_table 'uuid_tag_hierarchies', id: false do |t| + t.string 'ancestor_id', null: false + t.string 'descendant_id', null: false + t.integer 'generations', null: false end - create_table "cuisine_type_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id"], name: "index_cuisine_type_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_cuisine_type_hierarchies_on_descendant_id" + create_table 'destroyed_tags' do |t| + t.string 'name' end - create_table "cuisine_types", force: :cascade do |t| - t.string "name" - t.bigint "parent_id" - t.index ["parent_id"], name: "index_cuisine_types_on_parent_id" + add_index 'tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'tag_anc_desc_idx' + add_index 'tag_hierarchies', [:descendant_id], name: 'tag_desc_idx' + + create_table 'groups' do |t| + t.string 'name', null: false + end + + create_table 'groupings' do |t| + t.string 'name', null: false + end + + create_table 'user_sets' do |t| + t.string 'name', null: false + end + + create_table 'teams' do |t| + t.string 'name', null: false end - create_table "destroyed_tags", force: :cascade do |t| - t.string "name" + create_table 'users' do |t| + t.string 'email' + t.references 'referrer' + t.integer 'group_id' + t.timestamps null: false end - - create_table "groupings", force: :cascade do |t| - t.string "name", null: false + + create_table 'contracts' do |t| + t.references 'user', null: false + t.references 'contract_type' + t.string 'title' + end + + create_table 'contract_types' do |t| + t.string 'name', null: false end - create_table "groups", force: :cascade do |t| - t.string "name", null: false + create_table 'referral_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false end - create_table "label_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "lh_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_label_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_label_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "lh_desc_idx" - end + create_table 'labels' do |t| + t.string 'name' + t.string 'type' + t.integer 'column_whereby_ordering_is_inferred' + t.references 'mother' + end - create_table "labels", force: :cascade do |t| - t.integer "column_whereby_ordering_is_inferred" - t.bigint "mother_id" - t.string "name" - t.string "type" - t.index ["mother_id"], name: "index_labels_on_mother_id" - end - - create_table "lite_tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "lite_tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_lite_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_lite_tag_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "lite_tag_desc_idx" - end - - create_table "lite_tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_lite_tags_on_parent_id" + create_table 'label_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false end - create_table "memory_adoptable_tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "memory_adoptable_tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_memory_adoptable_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_memory_adoptable_tag_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "memory_adoptable_tag_desc_idx" + create_table 'cuisine_types' do |t| + t.string 'name' + t.references 'parent' end - create_table "memory_adoptable_tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_memory_adoptable_tags_on_parent_id" + create_table 'cuisine_type_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false end - create_table "menu_item_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id"], name: "index_menu_item_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_menu_item_hierarchies_on_descendant_id" + create_table 'namespace_types' do |t| + t.string 'name' + t.references 'parent' end - create_table "menu_items", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_menu_items_on_parent_id" + create_table 'namespace_type_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + # PostgreSQL schema-qualified tables + execute "CREATE SCHEMA IF NOT EXISTS test_schema" + + create_table 'test_schema.schema_types', force: true do |t| + t.string 'name' + t.references 'parent' + end + + create_table 'test_schema.schema_type_hierarchies', id: false, force: true do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + create_table 'metal' do |t| + t.references 'parent' + t.string 'metal_type' + t.string 'value' + t.string 'description' + t.integer 'sort_order' + end + + create_table 'metal_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + create_table 'menu_items' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false + end + + create_table 'menu_item_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'label_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'lh_anc_desc_idx' + add_index 'label_hierarchies', [:descendant_id], name: 'lh_desc_idx' + add_index 'referral_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'ref_anc_desc_idx' + add_index 'referral_hierarchies', [:descendant_id], name: 'ref_desc_idx' + + add_foreign_key(:tags, :tags, column: 'parent_id', on_delete: :cascade) + add_foreign_key(:users, :users, column: 'referrer_id', on_delete: :cascade) + add_foreign_key(:labels, :labels, column: 'mother_id', on_delete: :cascade) + add_foreign_key(:metal, :metal, column: 'parent_id', on_delete: :cascade) + add_foreign_key(:menu_items, :menu_items, column: 'parent_id', on_delete: :cascade) + add_foreign_key(:menu_item_hierarchies, :menu_items, column: 'ancestor_id', on_delete: :cascade) + add_foreign_key(:menu_item_hierarchies, :menu_items, column: 'descendant_id', on_delete: :cascade) + add_foreign_key(:tag_hierarchies, :tags, column: 'ancestor_id', on_delete: :cascade) + add_foreign_key(:tag_hierarchies, :tags, column: 'descendant_id', on_delete: :cascade) + + # Multi-database test models + create_table 'secondary_tags' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false + end + + create_table 'secondary_tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'secondary_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'secondary_tag_anc_desc_idx' + add_index 'secondary_tag_hierarchies', [:descendant_id], name: 'secondary_tag_desc_idx' + + create_table 'lite_tags' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false + end + + create_table 'lite_tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'lite_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'lite_tag_anc_desc_idx' + add_index 'lite_tag_hierarchies', [:descendant_id], name: 'lite_tag_desc_idx' + + create_table 'scoped_items' do |t| + t.string 'name' + t.references 'parent' + t.integer 'sort_order' + t.integer 'user_id' + t.integer 'group_id' + t.timestamps null: false + end + + create_table 'scoped_item_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'scoped_item_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'scoped_item_anc_desc_idx' + add_index 'scoped_item_hierarchies', [:descendant_id], name: 'scoped_item_desc_idx' + + create_table 'adoptable_tags' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false + end + + create_table 'adoptable_tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'adoptable_tag_anc_desc_idx' + add_index 'adoptable_tag_hierarchies', [:descendant_id], name: 'adoptable_tag_desc_idx' + + create_table 'secondary_adoptable_tags' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false + end + + create_table 'secondary_adoptable_tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false + end + + add_index 'secondary_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'secondary_adoptable_tag_anc_desc_idx' + add_index 'secondary_adoptable_tag_hierarchies', [:descendant_id], name: 'secondary_adoptable_tag_desc_idx' + + create_table 'memory_adoptable_tags' do |t| + t.string 'name' + t.references 'parent' + t.timestamps null: false end - create_table "metal", force: :cascade do |t| - t.string "description" - t.string "metal_type" - t.bigint "parent_id" - t.integer "sort_order" - t.string "value" - t.index ["parent_id"], name: "index_metal_on_parent_id" + create_table 'memory_adoptable_tag_hierarchies', id: false do |t| + t.references 'ancestor', null: false + t.references 'descendant', null: false + t.integer 'generations', null: false end - create_table "metal_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id"], name: "index_metal_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_metal_hierarchies_on_descendant_id" - end - - create_table "namespace_type_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id"], name: "index_namespace_type_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_namespace_type_hierarchies_on_descendant_id" - end - - create_table "namespace_types", force: :cascade do |t| - t.string "name" - t.bigint "parent_id" - t.index ["parent_id"], name: "index_namespace_types_on_parent_id" - end - - create_table "referral_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "ref_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_referral_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_referral_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "ref_desc_idx" - end - - create_table "scoped_item_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "scoped_item_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_scoped_item_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_scoped_item_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "scoped_item_desc_idx" - end - - create_table "scoped_items", force: :cascade do |t| - t.datetime "created_at", null: false - t.integer "group_id" - t.string "name" - t.bigint "parent_id" - t.integer "sort_order" - t.datetime "updated_at", null: false - t.integer "user_id" - t.index ["parent_id"], name: "index_scoped_items_on_parent_id" - end - - create_table "secondary_adoptable_tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_adoptable_tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_secondary_adoptable_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_secondary_adoptable_tag_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "secondary_adoptable_tag_desc_idx" - end - - create_table "secondary_adoptable_tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_secondary_adoptable_tags_on_parent_id" - end - - create_table "secondary_tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_secondary_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_secondary_tag_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "secondary_tag_desc_idx" - end - - create_table "secondary_tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_secondary_tags_on_parent_id" - end - - create_table "tag_hierarchies", id: false, force: :cascade do |t| - t.bigint "ancestor_id", null: false - t.bigint "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "tag_anc_desc_idx", unique: true - t.index ["ancestor_id"], name: "index_tag_hierarchies_on_ancestor_id" - t.index ["descendant_id"], name: "index_tag_hierarchies_on_descendant_id" - t.index ["descendant_id"], name: "tag_desc_idx" - end - - create_table "tags", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.bigint "parent_id" - t.integer "sort_order" - t.string "title" - t.datetime "updated_at", null: false - t.index ["parent_id"], name: "index_tags_on_parent_id" - end - - create_table "teams", force: :cascade do |t| - t.string "name", null: false - end - - create_table "user_sets", force: :cascade do |t| - t.string "name", null: false - end - - create_table "users", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "email" - t.integer "group_id" - t.bigint "referrer_id" - t.datetime "updated_at", null: false - t.index ["referrer_id"], name: "index_users_on_referrer_id" - end - - create_table "uuid_tag_hierarchies", id: false, force: :cascade do |t| - t.string "ancestor_id", null: false - t.string "descendant_id", null: false - t.integer "generations", null: false - end - - create_table "uuid_tags", primary_key: "uuid", id: :string, force: :cascade do |t| - t.datetime "created_at", null: false - t.string "name" - t.string "parent_uuid" - t.integer "sort_order" - t.string "title" - t.datetime "updated_at", null: false - end - - add_foreign_key "labels", "labels", column: "mother_id", on_delete: :cascade - add_foreign_key "menu_item_hierarchies", "menu_items", column: "ancestor_id", on_delete: :cascade - add_foreign_key "menu_item_hierarchies", "menu_items", column: "descendant_id", on_delete: :cascade - add_foreign_key "menu_items", "menu_items", column: "parent_id", on_delete: :cascade - add_foreign_key "metal", "metal", column: "parent_id", on_delete: :cascade - add_foreign_key "tag_hierarchies", "tags", column: "ancestor_id", on_delete: :cascade - add_foreign_key "tag_hierarchies", "tags", column: "descendant_id", on_delete: :cascade - add_foreign_key "tags", "tags", column: "parent_id", on_delete: :cascade - add_foreign_key "users", "users", column: "referrer_id", on_delete: :cascade + add_index 'memory_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'memory_adoptable_tag_anc_desc_idx' + add_index 'memory_adoptable_tag_hierarchies', [:descendant_id], name: 'memory_adoptable_tag_desc_idx' end diff --git a/test/dummy/db/secondary_schema.rb b/test/dummy/db/secondary_schema.rb index 09454804..f35d629f 100644 --- a/test/dummy/db/secondary_schema.rb +++ b/test/dummy/db/secondary_schema.rb @@ -1,43 +1,49 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 0) do - create_table "secondary_adoptable_tag_hierarchies", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "ancestor_id", null: false - t.integer "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_adoptable_tag_anc_desc_idx", unique: true - t.index ["descendant_id"], name: "secondary_adoptable_tag_desc_idx" +ActiveRecord::Schema.define(version: 0) do + create_table 'secondary_tags', force: true do |t| + t.string 'name' + t.integer 'parent_id' + t.datetime 'created_at' + t.datetime 'updated_at' end - create_table "secondary_adoptable_tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.datetime "created_at" - t.string "name" - t.integer "parent_id" - t.datetime "updated_at" + create_table 'secondary_tag_hierarchies', id: false, force: true do |t| + t.integer 'ancestor_id', null: false + t.integer 'descendant_id', null: false + t.integer 'generations', null: false end - create_table "secondary_tag_hierarchies", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "ancestor_id", null: false - t.integer "descendant_id", null: false - t.integer "generations", null: false - t.index ["ancestor_id", "descendant_id", "generations"], name: "secondary_tag_anc_des_idx", unique: true - t.index ["descendant_id"], name: "secondary_tag_desc_idx" + add_index 'secondary_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'secondary_tag_anc_des_idx' + add_index 'secondary_tag_hierarchies', [:descendant_id], name: 'secondary_tag_desc_idx' + + create_table 'secondary_adoptable_tags', force: true do |t| + t.string 'name' + t.integer 'parent_id' + t.datetime 'created_at' + t.datetime 'updated_at' end - create_table "secondary_tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.datetime "created_at" - t.string "name" - t.integer "parent_id" - t.datetime "updated_at" + create_table 'secondary_adoptable_tag_hierarchies', id: false, force: true do |t| + t.integer 'ancestor_id', null: false + t.integer 'descendant_id', null: false + t.integer 'generations', null: false end + + add_index 'secondary_adoptable_tag_hierarchies', %i[ancestor_id descendant_id generations], unique: true, + name: 'secondary_adoptable_tag_anc_desc_idx' + add_index 'secondary_adoptable_tag_hierarchies', [:descendant_id], name: 'secondary_adoptable_tag_desc_idx' end