mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
add public_id fields to relevant models and generate IDs
This commit is contained in:
4 files changed
+36
-2
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GeneratePublicIDsForModels < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
[Model, ModelFile, Problem, Creator, Collection, Library].each do |model|
|
||||
model.find_each do |obj|
|
||||
obj.update_attribute(:public_id, model.generate_cool_id) # rubocop:disable Rails/SkipsModelValidations
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -1 +1 @@
|
||||
DataMigrate::Data.define(version: 20240830151650)
|
||||
DataMigrate::Data.define(version: 20240904152358)
|
||||
@@ -0,0 +1,8 @@
|
||||
class AddPublicIDsToModels < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
[:models, :model_files, :problems, :creators, :collections, :libraries].each do |table|
|
||||
add_column table, :public_id, :string
|
||||
add_index table, :public_id
|
||||
end
|
||||
end
|
||||
end
|
||||
Generated
+13
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_09_04_151944) do
|
||||
create_table "caber_relations", force: :cascade do |t|
|
||||
t.string "subject_type"
|
||||
t.integer "subject_id"
|
||||
@@ -32,8 +32,10 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "collection_id"
|
||||
t.string "slug"
|
||||
t.string "public_id"
|
||||
t.index ["collection_id"], name: "index_collections_on_collection_id"
|
||||
t.index ["name"], name: "index_collections_on_name", unique: true
|
||||
t.index ["public_id"], name: "index_collections_on_public_id"
|
||||
t.index ["slug"], name: "index_collections_on_slug", unique: true
|
||||
end
|
||||
|
||||
@@ -44,7 +46,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.text "notes"
|
||||
t.text "caption"
|
||||
t.string "slug"
|
||||
t.string "public_id"
|
||||
t.index ["name"], name: "index_creators_on_name", unique: true
|
||||
t.index ["public_id"], name: "index_creators_on_public_id"
|
||||
t.index ["slug"], name: "index_creators_on_slug", unique: true
|
||||
end
|
||||
|
||||
@@ -141,6 +145,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.string "s3_bucket"
|
||||
t.string "s3_access_key_id"
|
||||
t.string "s3_secret_access_key"
|
||||
t.string "public_id"
|
||||
t.index ["public_id"], name: "index_libraries_on_public_id"
|
||||
end
|
||||
|
||||
create_table "links", force: :cascade do |t|
|
||||
@@ -165,10 +171,12 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.bigint "size"
|
||||
t.integer "presupported_version_id"
|
||||
t.json "attachment_data"
|
||||
t.string "public_id"
|
||||
t.index ["digest"], name: "index_model_files_on_digest"
|
||||
t.index ["filename", "model_id"], name: "index_model_files_on_filename_and_model_id", unique: true
|
||||
t.index ["model_id"], name: "index_model_files_on_model_id"
|
||||
t.index ["presupported_version_id"], name: "index_model_files_on_presupported_version_id"
|
||||
t.index ["public_id"], name: "index_model_files_on_public_id"
|
||||
end
|
||||
|
||||
create_table "models", force: :cascade do |t|
|
||||
@@ -184,11 +192,13 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.integer "collection_id"
|
||||
t.string "slug"
|
||||
t.string "license"
|
||||
t.string "public_id"
|
||||
t.index ["collection_id"], name: "index_models_on_collection_id"
|
||||
t.index ["creator_id"], name: "index_models_on_creator_id"
|
||||
t.index ["library_id"], name: "index_models_on_library_id"
|
||||
t.index ["path", "library_id"], name: "index_models_on_path_and_library_id", unique: true
|
||||
t.index ["preview_file_id"], name: "index_models_on_preview_file_id"
|
||||
t.index ["public_id"], name: "index_models_on_public_id"
|
||||
t.index ["slug"], name: "index_models_on_slug"
|
||||
end
|
||||
|
||||
@@ -200,8 +210,10 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_27_155630) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "note"
|
||||
t.boolean "ignored", default: false, null: false
|
||||
t.string "public_id"
|
||||
t.index ["category", "problematic_id", "problematic_type"], name: "index_problems_on_category_and_problematic_id_and_type", unique: true
|
||||
t.index ["problematic_type", "problematic_id"], name: "index_problems_on_problematic"
|
||||
t.index ["public_id"], name: "index_problems_on_public_id"
|
||||
end
|
||||
|
||||
create_table "roles", force: :cascade do |t|
|
||||
|
||||
Reference in new issue
Block a user