Files
fixin.me/db/migrate/20250104194343_create_quantities.rb
2026-05-05 20:36:51 +02:00

18 lines
569 B
Ruby

class CreateQuantities < ActiveRecord::Migration[8.1]
def change
create_table :quantities do |t|
t.references :user, foreign_key: {on_delete: :cascade}
t.string :name, null: false, limit: 31
t.text :description
t.references :parent, foreign_key: {to_table: :quantities, on_delete: :cascade}
t.timestamps
# Caches; can be computed from other attributes
t.integer :depth, null: false, default: 0
t.string :pathname, null: false, limit: 511
end
add_index :quantities, [:user_id, :parent_id, :name]
end
end