Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dashboard/db/migrate/20260513120000_create_scrapbook_entries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class CreateScrapbookEntries < ActiveRecord::Migration[7.0]
def change
create_table :scrapbook_entries do |t|
t.references :user, null: false, foreign_key: true, type: :integer
# An entry is keyed either by (script_id, level_id) for in-curriculum
# levels, or by channel_id for standalone projects. Both keyings are
# nullable; the model enforces that exactly one is present.
t.integer :script_id
t.integer :level_id
t.string :channel_id
# Image bytes live in S3; these columns hold only the bare filename
# reference (see Scrapbook::ImageStore).
t.string :before_asset_url
t.string :after_asset_url
t.text :entry_text
t.timestamps
end
# MySQL treats NULL as distinct, so each unique index only constrains rows
# whose key columns are non-NULL: the script_level rows ignore the channel
# index and vice versa.
add_index :scrapbook_entries, [:user_id, :script_id, :level_id], unique: true
add_index :scrapbook_entries, [:user_id, :channel_id], unique: true
end
end
16 changes: 16 additions & 0 deletions dashboard/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,21 @@
t.index ["zip"], name: "index_schools_on_zip"
end

create_table "scrapbook_entries", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "user_id", null: false
t.integer "script_id"
t.integer "level_id"
t.string "channel_id"
t.string "before_asset_url"
t.string "after_asset_url"
t.text "entry_text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id", "channel_id"], name: "index_scrapbook_entries_on_user_id_and_channel_id", unique: true
t.index ["user_id", "script_id", "level_id"], name: "index_scrapbook_entries_on_user_id_and_script_id_and_level_id", unique: true
t.index ["user_id"], name: "index_scrapbook_entries_on_user_id"
end

create_table "script_levels", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
t.integer "script_id", null: false
t.integer "chapter"
Expand Down Expand Up @@ -2969,6 +2984,7 @@
add_foreign_key "school_infos", "schools"
add_foreign_key "school_stats_by_years", "schools"
add_foreign_key "schools", "school_districts"
add_foreign_key "scrapbook_entries", "users"
add_foreign_key "scripts", "unit_groups", column: "original_unit_group_id"
add_foreign_key "section_instructors", "users", column: "instructor_id"
add_foreign_key "section_instructors", "users", column: "invited_by_id"
Expand Down
Loading