From 3de323cb39417b45da460cd5b7c8277ef54d9f6b Mon Sep 17 00:00:00 2001 From: Jan Suchal Date: Mon, 25 Nov 2024 08:03:33 +0100 Subject: [PATCH] Cleanup schema --- app/models/filter.rb | 5 +-- ...dd_jobs_finished_at_to_good_job_batches.rb | 17 -------- ...ate_good_job_execution_error_backtrace.rb} | 0 ...70057_create_good_job_process_lock_ids.rb} | 0 ...8_create_good_job_process_lock_indexes.rb} | 0 ...059_create_good_job_execution_duration.rb} | 0 db/schema.rb | 42 ++++--------------- 7 files changed, 8 insertions(+), 56 deletions(-) delete mode 100644 db/migrate/20241123214041_add_jobs_finished_at_to_good_job_batches.rb rename db/migrate/{20241123220542_create_good_job_execution_error_backtrace.rb => 20241125070056_create_good_job_execution_error_backtrace.rb} (100%) rename db/migrate/{20241123220543_create_good_job_process_lock_ids.rb => 20241125070057_create_good_job_process_lock_ids.rb} (100%) rename db/migrate/{20241123220544_create_good_job_process_lock_indexes.rb => 20241125070058_create_good_job_process_lock_indexes.rb} (100%) rename db/migrate/{20241123220545_create_good_job_execution_duration.rb => 20241125070059_create_good_job_execution_duration.rb} (100%) diff --git a/app/models/filter.rb b/app/models/filter.rb index 91ed2d75a..e64e2e8ef 100644 --- a/app/models/filter.rb +++ b/app/models/filter.rb @@ -3,15 +3,12 @@ # Table name: filters # # id :bigint not null, primary key -# is_pinned :boolean default(FALSE), not null # name :string not null # position :integer not null -# query :string -# type :string +# query :string not null # created_at :datetime not null # updated_at :datetime not null # author_id :bigint not null -# tag_id :bigint # tenant_id :bigint not null # class Filter < ApplicationRecord diff --git a/db/migrate/20241123214041_add_jobs_finished_at_to_good_job_batches.rb b/db/migrate/20241123214041_add_jobs_finished_at_to_good_job_batches.rb deleted file mode 100644 index 206ca8be3..000000000 --- a/db/migrate/20241123214041_add_jobs_finished_at_to_good_job_batches.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddJobsFinishedAtToGoodJobBatches < ActiveRecord::Migration[7.2] - def change - reversible do |dir| - dir.up do - # Ensure this incremental update migration is idempotent - # with monolithic install migration. - return if connection.column_exists?(:good_job_batches, :jobs_finished_at) - end - end - - change_table :good_job_batches do |t| - t.datetime :jobs_finished_at - end - end -end diff --git a/db/migrate/20241123220542_create_good_job_execution_error_backtrace.rb b/db/migrate/20241125070056_create_good_job_execution_error_backtrace.rb similarity index 100% rename from db/migrate/20241123220542_create_good_job_execution_error_backtrace.rb rename to db/migrate/20241125070056_create_good_job_execution_error_backtrace.rb diff --git a/db/migrate/20241123220543_create_good_job_process_lock_ids.rb b/db/migrate/20241125070057_create_good_job_process_lock_ids.rb similarity index 100% rename from db/migrate/20241123220543_create_good_job_process_lock_ids.rb rename to db/migrate/20241125070057_create_good_job_process_lock_ids.rb diff --git a/db/migrate/20241123220544_create_good_job_process_lock_indexes.rb b/db/migrate/20241125070058_create_good_job_process_lock_indexes.rb similarity index 100% rename from db/migrate/20241123220544_create_good_job_process_lock_indexes.rb rename to db/migrate/20241125070058_create_good_job_process_lock_indexes.rb diff --git a/db/migrate/20241123220545_create_good_job_execution_duration.rb b/db/migrate/20241125070059_create_good_job_execution_duration.rb similarity index 100% rename from db/migrate/20241123220545_create_good_job_execution_duration.rb rename to db/migrate/20241125070059_create_good_job_execution_duration.rb diff --git a/db/schema.rb b/db/schema.rb index 345920294..62be9fab8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_11_23_220545) do +ActiveRecord::Schema[7.2].define(version: 2024_11_06_152337) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -194,18 +194,13 @@ t.bigint "tenant_id", null: false t.bigint "author_id", null: false t.string "name", null: false - t.string "query" + t.string "query", null: false t.integer "position", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "type" - t.bigint "tag_id" - t.boolean "is_pinned", default: false, null: false t.index ["author_id"], name: "index_filters_on_author_id" - t.index ["is_pinned"], name: "index_filters_on_is_pinned" - t.index ["tag_id"], name: "index_filters_on_tag_id" + t.index ["tenant_id", "position"], name: "index_filters_on_tenant_id_and_position", unique: true t.index ["tenant_id"], name: "index_filters_on_tenant_id" - t.index ["type"], name: "index_filters_on_type" end create_table "folders", force: :cascade do |t| @@ -254,7 +249,6 @@ t.datetime "enqueued_at" t.datetime "discarded_at" t.datetime "finished_at" - t.datetime "jobs_finished_at" end create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -268,18 +262,13 @@ t.datetime "finished_at" t.text "error" t.integer "error_event", limit: 2 - t.text "error_backtrace", array: true - t.uuid "process_id" - t.interval "duration" t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at" - t.index ["process_id", "created_at"], name: "index_good_job_executions_on_process_id_and_created_at" end create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.jsonb "state" - t.integer "lock_type", limit: 2 end create_table "good_job_settings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -312,8 +301,6 @@ t.text "job_class" t.integer "error_event", limit: 2 t.text "labels", array: true - t.uuid "locked_by_id" - t.datetime "locked_at" t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at" t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)" t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)" @@ -322,10 +309,8 @@ t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)" t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))" t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin - t.index ["locked_by_id"], name: "index_good_jobs_on_locked_by_id", where: "(locked_by_id IS NOT NULL)" t.index ["priority", "created_at"], name: "index_good_job_jobs_for_candidate_lookup", where: "(finished_at IS NULL)" t.index ["priority", "created_at"], name: "index_good_jobs_jobs_on_priority_created_at_when_unfinished", order: { priority: "DESC NULLS LAST" }, where: "(finished_at IS NULL)" - t.index ["priority", "scheduled_at"], name: "index_good_jobs_on_priority_scheduled_at_unfinished_unlocked", where: "((finished_at IS NULL) AND (locked_by_id IS NULL))" t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)" t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" end @@ -465,7 +450,7 @@ t.datetime "delivered_at", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.datetime "last_message_delivered_at", precision: nil, null: false + t.datetime "last_message_delivered_at", null: false t.bigint "box_id", null: false t.index ["folder_id"], name: "index_message_threads_on_folder_id" end @@ -585,12 +570,12 @@ t.bigint "owner_id" t.string "external_name" t.string "type", null: false - t.enum "color", enum_type: "color" - t.integer "tag_groups_count", default: 0, null: false t.string "icon" + t.integer "tag_groups_count", default: 0, null: false + t.enum "color", enum_type: "color" t.index "tenant_id, type, lower((name)::text)", name: "index_tags_on_tenant_id_and_type_and_lowercase_name", unique: true t.index ["owner_id"], name: "index_tags_on_owner_id" - t.index ["tenant_id", "type"], name: "signings_tags", unique: true, where: "((type)::text = ANY (ARRAY[('SignatureRequestedTag'::character varying)::text, ('SignedTag'::character varying)::text]))" + t.index ["tenant_id", "type"], name: "signings_tags", unique: true, where: "((type)::text = ANY ((ARRAY['SignatureRequestedTag'::character varying, 'SignedTag'::character varying])::text[]))" t.index ["tenant_id"], name: "index_tags_on_tenant_id" end @@ -631,17 +616,6 @@ t.datetime "updated_at", null: false end - create_table "user_item_visibilities", force: :cascade do |t| - t.bigint "user_id", null: false - t.string "user_item_type", null: false - t.bigint "user_item_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "visible", default: true, null: false - t.integer "position" - t.index ["user_id"], name: "index_user_item_visibilities_on_user_id" - end - create_table "users", force: :cascade do |t| t.bigint "tenant_id" t.string "email", null: false @@ -672,7 +646,6 @@ add_foreign_key "filter_subscriptions", "filters" add_foreign_key "filter_subscriptions", "tenants" add_foreign_key "filter_subscriptions", "users" - add_foreign_key "filters", "tags" add_foreign_key "filters", "tenants", on_delete: :cascade add_foreign_key "filters", "users", column: "author_id", on_delete: :cascade add_foreign_key "folders", "boxes" @@ -713,6 +686,5 @@ add_foreign_key "tags", "tenants" add_foreign_key "tags", "users", column: "owner_id" add_foreign_key "upvs_form_related_documents", "upvs_forms" - add_foreign_key "user_item_visibilities", "users" add_foreign_key "users", "tenants" end