add revisions
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateTemplateVersions < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :template_versions do |t|
|
||||
t.references :template, null: false, foreign_key: true, index: false
|
||||
t.references :account, null: false, foreign_key: true, index: true
|
||||
t.references :author, null: false, foreign_key: { to_table: :users }, index: true
|
||||
t.text :data, null: false
|
||||
t.string :sha1, null: false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :template_versions, %i[template_id sha1], unique: true
|
||||
end
|
||||
end
|
||||
+17
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_05_06_120000) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_05_06_121640) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
@@ -444,6 +444,19 @@ ActiveRecord::Schema[8.1].define(version: 2026_05_06_120000) do
|
||||
t.index ["template_id"], name: "index_template_sharings_on_template_id"
|
||||
end
|
||||
|
||||
create_table "template_versions", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "author_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.text "data", null: false
|
||||
t.string "sha1", null: false
|
||||
t.bigint "template_id", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_template_versions_on_account_id"
|
||||
t.index ["author_id"], name: "index_template_versions_on_author_id"
|
||||
t.index ["template_id", "sha1"], name: "index_template_versions_on_template_id_and_sha1", unique: true
|
||||
end
|
||||
|
||||
create_table "templates", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "archived_at"
|
||||
@@ -587,6 +600,9 @@ ActiveRecord::Schema[8.1].define(version: 2026_05_06_120000) do
|
||||
add_foreign_key "template_folders", "template_folders", column: "parent_folder_id"
|
||||
add_foreign_key "template_folders", "users", column: "author_id"
|
||||
add_foreign_key "template_sharings", "templates"
|
||||
add_foreign_key "template_versions", "accounts"
|
||||
add_foreign_key "template_versions", "templates"
|
||||
add_foreign_key "template_versions", "users", column: "author_id"
|
||||
add_foreign_key "templates", "accounts"
|
||||
add_foreign_key "templates", "template_folders", column: "folder_id"
|
||||
add_foreign_key "templates", "users", column: "author_id"
|
||||
|
||||
Reference in New Issue
Block a user