diff --git a/server/db/migrate/20240725165912_add_unique_index_to_new_views.rb b/server/db/migrate/20240725165912_add_unique_index_to_new_views.rb new file mode 100644 index 000000000..b0b5fb5cc --- /dev/null +++ b/server/db/migrate/20240725165912_add_unique_index_to_new_views.rb @@ -0,0 +1,6 @@ +class AddUniqueIndexToNewViews < ActiveRecord::Migration[7.1] + def change + add_index :user_browse_table_rows, :id, unique: true + add_index :organization_browse_table_rows, :id, unique: true + end +end diff --git a/server/db/schema.rb b/server/db/schema.rb index 3f99f9f3a..91dee13f6 100644 --- a/server/db/schema.rb +++ b/server/db/schema.rb @@ -10,12 +10,15 @@ # # It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.1].define(version: 2024_06_28_151626) do - +ActiveRecord::Schema[7.1].define(version: 2024_07_25_165912) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + # Custom types defined in this database. + # Note that some types may not work with other database engines. Be careful if changing database. + create_enum "exon_offset_direction", ["positive", "negative"] + create_enum "fusion_partner_status", ["known", "unknown", "multiple"] + create_table "acmg_codes", id: :serial, force: :cascade do |t| t.text "code" t.text "description" @@ -499,6 +502,17 @@ t.index ["state"], name: "index_flags_on_state" end + create_table "fusions", force: :cascade do |t| + t.bigint "five_prime_gene_id" + t.bigint "three_prime_gene_id" + t.enum "five_prime_partner_status", default: "unknown", null: false, enum_type: "fusion_partner_status" + t.enum "three_prime_partner_status", default: "unknown", null: false, enum_type: "fusion_partner_status" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["five_prime_gene_id"], name: "index_fusions_on_five_prime_gene_id" + t.index ["three_prime_gene_id"], name: "index_fusions_on_three_prime_gene_id" + end + create_table "gene_aliases", id: :serial, force: :cascade do |t| t.string "name" t.index ["name"], name: "index_gene_aliases_on_name" @@ -884,6 +898,7 @@ t.text "coordinate_type", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.enum "exon_offset_direction", enum_type: "exon_offset_direction" t.index ["chromosome"], name: "index_variant_coordinates_on_chromosome" t.index ["reference_build"], name: "index_variant_coordinates_on_reference_build" t.index ["representative_transcript"], name: "index_variant_coordinates_on_representative_transcript" @@ -965,6 +980,7 @@ t.bigint "feature_id" t.string "type", null: false t.string "ncit_id" + t.string "vicc_compliant_name" t.index "lower((name)::text) varchar_pattern_ops", name: "idx_case_insensitive_variant_name" t.index "lower((name)::text)", name: "variant_lower_name_idx" t.index ["chromosome"], name: "index_variants_on_chromosome" @@ -981,6 +997,7 @@ t.index ["stop"], name: "index_variants_on_stop" t.index ["stop2"], name: "index_variants_on_stop2" t.index ["variant_bases"], name: "index_variants_on_variant_bases" + t.index ["vicc_compliant_name"], name: "index_variants_on_vicc_compliant_name" end create_table "view_last_updated_timestamps", force: :cascade do |t| @@ -1032,6 +1049,8 @@ add_foreign_key "feature_aliases_features", "features" add_foreign_key "features_sources", "features" add_foreign_key "features_sources", "sources" + add_foreign_key "fusions", "genes", column: "five_prime_gene_id" + add_foreign_key "fusions", "genes", column: "three_prime_gene_id" add_foreign_key "gene_aliases_genes", "gene_aliases" add_foreign_key "gene_aliases_genes", "genes" add_foreign_key "genes_sources", "genes" @@ -1401,7 +1420,8 @@ LEFT JOIN organizations child ON ((child.parent_id = organizations.id))) GROUP BY organizations.id; SQL - + add_index "organization_browse_table_rows", ["id"], name: "index_organization_browse_table_rows_on_id", unique: true + create_view "user_browse_table_rows", materialized: true, sql_definition: <<-SQL SELECT users.id, users.email, @@ -1432,4 +1452,6 @@ LEFT JOIN events ON ((events.originating_user_id = users.id))) GROUP BY users.id; SQL + add_index "user_browse_table_rows", ["id"], name: "index_user_browse_table_rows_on_id", unique: true + end