add source to templates
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
# name :string not null
|
||||
# schema :text not null
|
||||
# slug :string not null
|
||||
# source :text not null
|
||||
# submitters :text not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
@@ -37,6 +38,7 @@ class Template < ApplicationRecord
|
||||
attribute :schema, :string, default: -> { [] }
|
||||
attribute :submitters, :string, default: -> { [{ name: DEFAULT_SUBMITTER_NAME, uuid: SecureRandom.uuid }] }
|
||||
attribute :slug, :string, default: -> { SecureRandom.base58(14) }
|
||||
attribute :source, :string, default: 'native'
|
||||
|
||||
serialize :fields, JSON
|
||||
serialize :schema, JSON
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddSourceToTemplates < ActiveRecord::Migration[7.0]
|
||||
class MigrationTemplate < ApplicationRecord
|
||||
self.table_name = 'templates'
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :templates, :source, :text
|
||||
|
||||
MigrationTemplate.where(source: nil).update_all(source: :native)
|
||||
|
||||
change_column_null :templates, :source, false
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :templates, :source
|
||||
end
|
||||
end
|
||||
+2
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_19_113427) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_19_190316) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -134,6 +134,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_19_113427) do
|
||||
t.datetime "deleted_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "source", null: false
|
||||
t.index ["account_id"], name: "index_templates_on_account_id"
|
||||
t.index ["author_id"], name: "index_templates_on_author_id"
|
||||
t.index ["slug"], name: "index_templates_on_slug", unique: true
|
||||
|
||||
Reference in New Issue
Block a user