Add TicketType model with validations and fix dropdown menu
- Create TicketType model with Party association and Ticket relationship - Add comprehensive validations for name, description, pricing, and date ranges - Generate migration for ticket_types table with all required fields - Add Alpine.js import to fix dropdown menu functionality - Update ticket model with validations for qr_code, price, and status
This commit is contained in:
17
db/migrate/20250823170408_create_ticket_types.rb
Normal file
17
db/migrate/20250823170408_create_ticket_types.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class CreateTicketTypes < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :ticket_types do |t|
|
||||
t.references :party, null: false, foreign_key: true
|
||||
t.string :name
|
||||
t.text :description
|
||||
t.integer :price_cents
|
||||
t.integer :quantity
|
||||
t.datetime :sale_start_at
|
||||
t.datetime :sale_end_at
|
||||
t.boolean :requires_id
|
||||
t.integer :minimum_age
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
db/migrate/20250823171354_create_tickets.rb
Normal file
9
db/migrate/20250823171354_create_tickets.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class CreateTickets < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :tickets do |t|
|
||||
t.string :qr_code
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
25
db/schema.rb
generated
25
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_08_23_145902) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_08_23_171354) do
|
||||
create_table "parties", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "description", null: false
|
||||
@@ -27,6 +27,27 @@ ActiveRecord::Schema[8.0].define(version: 2025_08_23_145902) do
|
||||
t.index ["state"], name: "index_parties_on_state"
|
||||
end
|
||||
|
||||
create_table "ticket_types", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.bigint "party_id", null: false
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.integer "price_cents"
|
||||
t.integer "quantity"
|
||||
t.datetime "sale_start_at"
|
||||
t.datetime "sale_end_at"
|
||||
t.boolean "requires_id"
|
||||
t.integer "minimum_age"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["party_id"], name: "index_ticket_types_on_party_id"
|
||||
end
|
||||
|
||||
create_table "tickets", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "qr_code"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "users", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
@@ -38,4 +59,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_08_23_145902) do
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "ticket_types", "parties"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user