This commit is contained in:
Trevor Vallender 2023-12-29 11:27:45 +00:00
parent e1e3ef94be
commit 7615febc5d
5 changed files with 29 additions and 3 deletions

3
app/models/food.rb Normal file
View File

@ -0,0 +1,3 @@
class Food < ApplicationRecord
validates :name, presence: true
end

View File

@ -3,12 +3,14 @@ default: &default
encoding: unicode encoding: unicode
# For details on connection pooling, see Rails configuration guide # For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling # https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> host: localhost
username: soc username: postgres
password: postgres
development: development:
<<: *default <<: *default
database: soc_development database: soc_development
username: postgres
password: postgres password: postgres
test: test:
@ -20,3 +22,4 @@ production:
database: soc_production database: soc_production
password: <%= ENV["POSTGRES_PASSWORD"] %> password: <%= ENV["POSTGRES_PASSWORD"] %>
host: <%= ENV.fetch("DB_HOST") { 'localhost' } %> host: <%= ENV.fetch("DB_HOST") { 'localhost' } %>
username: soc

View File

@ -0,0 +1,9 @@
class CreateFoods < ActiveRecord::Migration[7.1]
def change
create_table :foods do |t|
t.text :name, null: false
t.timestamps
end
end
end

8
db/schema.rb generated
View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2023_10_19_192600) do ActiveRecord::Schema[7.1].define(version: 2023_12_29_112620) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -63,6 +63,12 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_192600) do
t.index ["user_id"], name: "index_blog_posts_on_user_id" t.index ["user_id"], name: "index_blog_posts_on_user_id"
end end
create_table "foods", force: :cascade do |t|
t.text "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "microposts", force: :cascade do |t| create_table "microposts", force: :cascade do |t|
t.bigint "user_id", null: false t.bigint "user_id", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false

5
test/fixtures/foods.yml vendored Normal file
View File

@ -0,0 +1,5 @@
one:
name: Pizza
two:
name: Banana