From 82408a8e03414d5814cdef0342dfa13f692532f0 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 6 Mar 2025 13:57:11 +0530 Subject: [PATCH] feat: add delete requests table --- app/models/delete_request.rb | 23 +++++++++++++++++++ .../20250306135111_create_delete_requests.rb | 17 ++++++++++++++ db/schema.rb | 16 ++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/models/delete_request.rb create mode 100644 db/migrate/20250306135111_create_delete_requests.rb diff --git a/app/models/delete_request.rb b/app/models/delete_request.rb new file mode 100644 index 000000000..017d74496 --- /dev/null +++ b/app/models/delete_request.rb @@ -0,0 +1,23 @@ +# == Schema Information +# +# Table name: delete_requests +# +# id :bigint not null, primary key +# completed_at :datetime +# confirmation_code :string not null +# deleted_type :string +# status :string not null +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint +# deleted_id :integer +# fb_id :string not null +# +# Indexes +# +# index_delete_requests_on_account_id (account_id) +# index_delete_requests_on_confirmation_code (confirmation_code) UNIQUE +# +class DeleteRequest < ApplicationRecord + belongs_to :account +end diff --git a/db/migrate/20250306135111_create_delete_requests.rb b/db/migrate/20250306135111_create_delete_requests.rb new file mode 100644 index 000000000..58bb39ef4 --- /dev/null +++ b/db/migrate/20250306135111_create_delete_requests.rb @@ -0,0 +1,17 @@ +class CreateDeleteRequests < ActiveRecord::Migration[7.0] + def change + create_table :delete_requests do |t| + t.string :fb_id, null: false + t.string :status, null: false + t.string :confirmation_code, null: false + t.datetime :completed_at + t.string :deleted_type + t.integer :deleted_id + t.references :account, index: true, null: true + + t.timestamps + end + + add_index :delete_requests, :confirmation_code, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index a68593c68..7ab1282dd 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.0].define(version: 2025_02_28_185548) do +ActiveRecord::Schema[7.0].define(version: 2025_03_06_081627) do # These extensions should be enabled to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm" @@ -639,6 +639,20 @@ ActiveRecord::Schema[7.0].define(version: 2025_02_28_185548) do t.index ["account_id"], name: "index_data_imports_on_account_id" end + create_table "delete_requests", force: :cascade do |t| + t.string "fb_id", null: false + t.string "status", null: false + t.string "confirmation_code", null: false + t.datetime "completed_at" + t.string "deleted_type" + t.integer "deleted_id" + t.bigint "account_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_id"], name: "index_delete_requests_on_account_id" + t.index ["confirmation_code"], name: "index_delete_requests_on_confirmation_code", unique: true + end + create_table "email_templates", force: :cascade do |t| t.string "name", null: false t.text "body", null: false