From f66957dd3d3b934abc0b2166d9d848186e0ae5e8 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Thu, 11 Jul 2024 20:11:04 +0200 Subject: [PATCH] Include guests in seed --- Gemfile | 1 + Gemfile.lock | 3 +++ db/migrate/20240711180753_create_guests.rb | 2 +- db/schema.rb | 2 +- db/seeds.rb | 8 ++++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index ed9e507..9969c65 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ] gem 'rspec-rails', '~> 6.1.0' + gem 'faker' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index e3c0418..0a4cb1f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,6 +91,8 @@ GEM diff-lcs (1.5.0) drb (2.2.1) erubi (1.13.0) + faker (3.1.1) + i18n (>= 1.8.11, < 2) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.5) @@ -252,6 +254,7 @@ PLATFORMS DEPENDENCIES bootsnap debug + faker importmap-rails jbuilder money diff --git a/db/migrate/20240711180753_create_guests.rb b/db/migrate/20240711180753_create_guests.rb index 8e62076..1280006 100644 --- a/db/migrate/20240711180753_create_guests.rb +++ b/db/migrate/20240711180753_create_guests.rb @@ -1,6 +1,6 @@ class CreateGuests < ActiveRecord::Migration[7.1] def change - create_table :guests do |t| + create_table :guests, id: :uuid do |t| t.string :first_name t.string :last_name t.string :email diff --git a/db/schema.rb b/db/schema.rb index 9eb19ab..4e13f74 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -26,7 +26,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_11_180753) do t.datetime "updated_at", null: false end - create_table "guests", force: :cascade do |t| + create_table "guests", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "first_name" t.string "last_name" t.string "email" diff --git a/db/seeds.rb b/db/seeds.rb index 15c0a1e..b21fb7b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,6 +9,7 @@ # end Expense.delete_all +Guest.delete_all Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed') Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed') @@ -24,3 +25,10 @@ Expense.create!(name: 'Hair', amount: 200, pricing_type: 'fixed') Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed') Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed') Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed') + +300.times do + Guest.create!(first_name: Faker::Name.first_name, + last_name: Faker::Name.last_name, + email: Faker::Internet.email, + phone: Faker::PhoneNumber.cell_phone) +end