Use composite primary key on asset_attachments
Drop the surrogate id in favour of a composite primary key on
(asset_id, file_id), which both removes the unnecessary column and
enforces uniqueness at the schema level.
diff --git a/db/migrate/004_create_asset_attachments.rb b/db/migrate/004_create_asset_attachments.rb
index a9914cf..432abea 100644
--- a/db/migrate/004_create_asset_attachments.rb
+++ b/db/migrate/004_create_asset_attachments.rb
@@ -3,10 +3,10 @@
Sequel.migration do
change do
create_table(:asset_attachments) do
- primary_key :id
foreign_key :asset_id, :assets, null: false
foreign_key :file_id, :files, null: false
DateTime :created_at, null: false
+ primary_key [:asset_id, :file_id]
end
end
end