From d03d7901554d0a66bf908f14244160694b2b395c Mon Sep 17 00:00:00 2001 From: moveson Date: Wed, 18 Dec 2024 17:43:27 -0700 Subject: [PATCH 1/2] Migration to create a file_downloads table --- .../20241219004057_create_file_downloads.rb | 11 +++++++++++ db/schema.rb | 14 +++++++++++++- erd.pdf | Bin 76461 -> 76461 bytes 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20241219004057_create_file_downloads.rb diff --git a/db/migrate/20241219004057_create_file_downloads.rb b/db/migrate/20241219004057_create_file_downloads.rb new file mode 100644 index 000000000..e1953153a --- /dev/null +++ b/db/migrate/20241219004057_create_file_downloads.rb @@ -0,0 +1,11 @@ +class CreateFileDownloads < ActiveRecord::Migration[7.0] + def change + create_table :file_downloads do |t| + t.references :user, null: false, foreign_key: true + t.references :record, polymorphic: true, null: false + t.string :name, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1ab415af9..d8df9d61a 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: 2024_12_18_183211) do +ActiveRecord::Schema[7.0].define(version: 2024_12_19_004057) do # These are extensions that must be enabled in order to support this database enable_extension "fuzzystrmatch" enable_extension "pg_trgm" @@ -255,6 +255,17 @@ t.index ["user_id"], name: "index_export_jobs_on_user_id" end + create_table "file_downloads", force: :cascade do |t| + t.bigint "user_id", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["record_type", "record_id"], name: "index_file_downloads_on_record" + t.index ["user_id"], name: "index_file_downloads_on_user_id" + end + create_table "friendly_id_slugs", force: :cascade do |t| t.string "slug", null: false t.integer "sluggable_id", null: false @@ -769,6 +780,7 @@ add_foreign_key "events", "courses" add_foreign_key "events", "event_groups" add_foreign_key "export_jobs", "users" + add_foreign_key "file_downloads", "users" add_foreign_key "historical_facts", "organizations" add_foreign_key "historical_facts", "people" add_foreign_key "import_jobs", "users" diff --git a/erd.pdf b/erd.pdf index 18deb6942556174eaab65d796ee0e6a13bccaa57..9fbe38cbb07b53fb73b6347ae1c58ea9e36f24f8 100644 GIT binary patch delta 587 zcmV-R0<`_D)da281c0;w+b4f(!Y~-c@BJ&@WlRrilbEI=#e)hm#z3mKu|tTV21Zko zbj<&LNwtoV)A!?hdGGO2kW7>)Nyb1+nhAkLC9=9kak};z#X+{(X8?*fbN2WE13`n& z5pC_z1<-809u)^?&x6tqGbN3)pgCRU46{oJy%md zp2#}>T;o_b1WzT63n_=LFnom3wtT|aubk-eASSw)e39>%;vSb?!c0;>?csV#?#VOR z(mt=4^)OeG+A8-T-{chYMXh%{U*5?D=eB(M?b$N_0UKm>gn5D5VgR+)58Z7LK4; zMv_bO_m!MDrRcKz*wM_g43vl^mXvU?B_l#$u@a;#k)N-vB7?Wj07+YCxO%#<|Ff@N%-am+3u^nR1)BW<1RFGl&yx^{m)zkTDh490e~ z3>vd~!znKqXKTh5v3Q}YXG-Uj$zLoyMeC$LNT*Ydlxzg=x-oKRe_~u3UqM9y&Zv0A z?m`rJ6c5GT*`Y^SrY7|_myu5B6seP)?~|LlPWTnU4SMRTI92O!qx5mVOE9KR{HVPh zoYEePhvz8@Rk(%s@eURL7OZ5DU$(vP7jJN1FAn_z`nqpGm+dG49|AZqmkucbEde!` z;UfVVlW>6qmsu$RMt=fO7{&4DnixbV4k?B&`I2HN4S~?m;s*3MC~)Peuw{@*B_q From 584a39ee3f0bf9e4a10612e9216e7709eb4e68c1 Mon Sep 17 00:00:00 2001 From: moveson Date: Wed, 18 Dec 2024 17:50:22 -0700 Subject: [PATCH 2/2] Add filename and byte_size to file_downloads table --- .../20241219004057_create_file_downloads.rb | 2 ++ db/schema.rb | 2 ++ erd.pdf | Bin 76461 -> 76461 bytes 3 files changed, 4 insertions(+) diff --git a/db/migrate/20241219004057_create_file_downloads.rb b/db/migrate/20241219004057_create_file_downloads.rb index e1953153a..10f9cf966 100644 --- a/db/migrate/20241219004057_create_file_downloads.rb +++ b/db/migrate/20241219004057_create_file_downloads.rb @@ -4,6 +4,8 @@ def change t.references :user, null: false, foreign_key: true t.references :record, polymorphic: true, null: false t.string :name, null: false + t.string :filename, null: false + t.string :byte_size, null: false t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index d8df9d61a..89844e8e0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -260,6 +260,8 @@ t.string "record_type", null: false t.bigint "record_id", null: false t.string "name", null: false + t.string "filename", null: false + t.string "byte_size", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["record_type", "record_id"], name: "index_file_downloads_on_record" diff --git a/erd.pdf b/erd.pdf index 9fbe38cbb07b53fb73b6347ae1c58ea9e36f24f8..4befaeca83a7cfea92a2455e89a0e158a803aedc 100644 GIT binary patch delta 587 zcmV-R0<`_D)da281c0;w+$Vp7Fc`(}{uS>sW)G`Ls%clGhgv9O48-m>b_g+8VHio` zSpWMaS{);&@5lG@-s7Vn5zmm3h=FD_;vAbTkMbPJ`>j_e*HQlWl;;VDL-6zRN8zcH_EA3jFX0?BszA;L;R(B`i z6ynpK5tdR$cXXRR6aGZDkA$pdlfPJa@YX?J3Zp`fkZc5Rs&2(m|MJKg^w1;E!w}}lWu!B@cxpsv``{*TGk$?HgPNzpZ=KY4D^+zq2Ix}4vnzk`EI>i^L4<8bcs++$|8Sa{5WX42!V{%q#V0$6XUS8gA!bg3`$ zXPLZyhuI6<*}}-2*GUbpx_F(V&sCL=@V+5?_z;ps?8uK9e-8XOOvn{5*Cm3qVCk#*JT$g)syN%Ho`HnH}aq&$|MD^2GOvdDaJeLja z)5r7xGX<%wGLQ02{^9PP);s-Q-pMuR@WN%_> Z3UhQ}a&&ldm!2vC2M9F^B_%~qMhbPdAHDzp delta 586 zcmV-Q0=50E)da281c0;w+$Vp+Fc`(}{VU#OOb=_5n5H7dg9 z%>RB#wT_X~_v3qc@9|NPOq3`|#z0G&34ui=v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