diff --git a/db/migrate/20230602185352_create_units.rb b/db/migrate/20230602185352_create_units.rb index 4b5f64c..af0cc04 100644 --- a/db/migrate/20230602185352_create_units.rb +++ b/db/migrate/20230602185352_create_units.rb @@ -5,7 +5,7 @@ class CreateUnits < ActiveRecord::Migration[7.0] t.string :symbol, null: false, limit: 15 t.text :description t.decimal :multiplier, null: false, precision: 30, scale: 15, default: 1.0 - t.references :base + t.references :base, foreign_key: {to_table: :units} t.timestamps null: false end diff --git a/db/migrate/20250104194343_create_quantities.rb b/db/migrate/20250104194343_create_quantities.rb new file mode 100644 index 0000000..1cdb7bc --- /dev/null +++ b/db/migrate/20250104194343_create_quantities.rb @@ -0,0 +1,13 @@ +class CreateQuantities < ActiveRecord::Migration[7.2] + def change + create_table :quantities do |t| + t.references :user, foreign_key: true + t.integer :domain + t.string :name, null: false, limit: 31 + t.text :description + t.references :parent, foreign_key: {to_table: :quantities} + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0006b01..213db6f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2023_06_02_185352) do +ActiveRecord::Schema[7.2].define(version: 2025_01_04_194343) do + create_table "quantities", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "user_id" + t.integer "domain" + t.string "name", limit: 31, null: false + t.text "description" + t.bigint "parent_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["parent_id"], name: "index_quantities_on_parent_id" + t.index ["user_id"], name: "index_quantities_on_user_id" + end + create_table "units", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.bigint "user_id" t.string "symbol", limit: 15, null: false @@ -42,5 +54,8 @@ ActiveRecord::Schema[7.2].define(version: 2023_06_02_185352) do t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + add_foreign_key "quantities", "quantities", column: "parent_id" + add_foreign_key "quantities", "users" + add_foreign_key "units", "units", column: "base_id" add_foreign_key "units", "users" end