Create models to store tables arrangements
This commit is contained in:
parent
405e698a6f
commit
7926928feb
4
app/models/seat.rb
Normal file
4
app/models/seat.rb
Normal file
@ -0,0 +1,4 @@
|
||||
class Seat < ApplicationRecord
|
||||
belongs_to :guest
|
||||
belongs_to :table_arrangement
|
||||
end
|
2
app/models/tables_arrangement.rb
Normal file
2
app/models/tables_arrangement.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class TablesArrangement < ApplicationRecord
|
||||
end
|
8
db/migrate/20240724181756_create_tables_arrangements.rb
Normal file
8
db/migrate/20240724181756_create_tables_arrangements.rb
Normal file
@ -0,0 +1,8 @@
|
||||
class CreateTablesArrangements < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :tables_arrangements, id: :uuid do |t|
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/migrate/20240724181853_create_seats.rb
Normal file
13
db/migrate/20240724181853_create_seats.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class CreateSeats < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :seats, id: :uuid do |t|
|
||||
t.references :guest, null: false, foreign_key: true, type: :uuid
|
||||
t.references :tables_arrangement, null: false, type: :uuid
|
||||
t.integer :table_number
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_foreign_key :seats, :tables_arrangements, on_delete: :cascade
|
||||
end
|
||||
end
|
19
db/schema.rb
generated
19
db/schema.rb
generated
@ -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_07_11_181632) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_07_24_181853) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@ -35,6 +35,21 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_11_181632) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "seats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "guest_id", null: false
|
||||
t.uuid "tables_arrangement_id", null: false
|
||||
t.integer "table_number"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["guest_id"], name: "index_seats_on_guest_id"
|
||||
t.index ["tables_arrangement_id"], name: "index_seats_on_tables_arrangement_id"
|
||||
end
|
||||
|
||||
create_table "tables_arrangements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "taggings", force: :cascade do |t|
|
||||
t.bigint "tag_id"
|
||||
t.string "taggable_type"
|
||||
@ -66,5 +81,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_11_181632) do
|
||||
t.index ["name"], name: "index_tags_on_name", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "seats", "guests"
|
||||
add_foreign_key "seats", "tables_arrangements", on_delete: :cascade
|
||||
add_foreign_key "taggings", "tags"
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
NUMBER_OF_GUESTS = 50
|
||||
|
||||
TablesArrangement.delete_all
|
||||
Expense.delete_all
|
||||
Guest.delete_all
|
||||
ActsAsTaggableOn::Tagging.delete_all
|
||||
|
5
spec/models/seat_spec.rb
Normal file
5
spec/models/seat_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Seat, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
5
spec/models/tables_arrangement_spec.rb
Normal file
5
spec/models/tables_arrangement_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TablesArrangement, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user