···1+class AddImportCollections < ActiveRecord::Migration[7.2]
2+ def change
3+ add_column :imports, :collection, :string, limit: 20, null: true
4+5+ reversible do |dir|
6+ dir.up do
7+ execute "UPDATE imports SET collection = 'likes'"
8+ end
9+ end
10+11+ change_column_null :imports, :collection, false
12+13+ remove_index :imports, :user_id, unique: true
14+ add_index :imports, [:user_id, :collection], unique: true
15+16+ reversible do |dir|
17+ dir.down do
18+ execute "DELETE FROM imports WHERE collection != 'likes'"
19+ end
20+ end
21+ end
22+end
+3-2
db/schema.rb
···10#
11# It's strongly recommended that you check this file into your version control system.
1213-ActiveRecord::Schema[7.2].define(version: 2025_08_31_210930) do
14 # These are extensions that must be enabled in order to support this database
15 enable_extension "plpgsql"
16···19 t.string "cursor"
20 t.datetime "started_from"
21 t.datetime "last_completed"
22- t.index ["user_id"], name: "index_imports_on_user_id", unique: true
023 end
2425 create_table "likes", force: :cascade do |t|
···10#
11# It's strongly recommended that you check this file into your version control system.
1213+ActiveRecord::Schema[7.2].define(version: 2025_09_03_215014) do
14 # These are extensions that must be enabled in order to support this database
15 enable_extension "plpgsql"
16···19 t.string "cursor"
20 t.datetime "started_from"
21 t.datetime "last_completed"
22+ t.string "collection", limit: 20, null: false
23+ t.index ["user_id", "collection"], name: "index_imports_on_user_id_and_collection", unique: true
24 end
2526 create_table "likes", force: :cascade do |t|