add postgres with docker

This commit is contained in:
Mohammad Kanaan 2026-05-25 19:11:54 +03:00
parent 2cc3c1a7dd
commit 5b56b091b4
6 changed files with 176 additions and 47 deletions

View file

@ -2,8 +2,8 @@ source "https://rubygems.org"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.0.4"
# Use sqlite3 as the database for Active Record
gem "sqlite3", ">= 2.1"
# Use pg as the database for Active Record
gem "pg", "~> 1.5"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
@ -44,4 +44,9 @@ group :development, :test do
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
gem 'rails-erd', require: false
gem "annotaterb"
gem "dotenv-rails"
end

View file

@ -72,6 +72,9 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
annotaterb (4.22.0)
activerecord (>= 6.0.0)
activesupport (>= 6.0.0)
ast (2.4.3)
base64 (0.3.0)
bcrypt_pbkdf (1.1.2)
@ -82,6 +85,7 @@ GEM
brakeman (8.0.4)
racc
builder (3.3.0)
choice (0.2.0)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
@ -90,6 +94,9 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
dotenv (3.2.0)
dotenv-rails (3.2.0)
dotenv (= 3.2.0)
railties (>= 6.1)
drb (2.2.3)
ed25519 (1.4.0)
erb (6.0.4)
@ -173,6 +180,12 @@ GEM
parser (3.3.11.1)
ast (~> 2.4.1)
racc
pg (1.6.3)
pg (1.6.3-aarch64-linux)
pg (1.6.3-aarch64-linux-musl)
pg (1.6.3-arm64-darwin)
pg (1.6.3-x86_64-linux)
pg (1.6.3-x86_64-linux-musl)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
@ -210,6 +223,11 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.7.0)
loofah (~> 2.25)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
@ -231,6 +249,7 @@ GEM
regexp_parser (2.12.0)
reline (0.6.3)
io-console (~> 0.5)
rexml (3.4.4)
rubocop (1.86.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
@ -259,6 +278,8 @@ GEM
rubocop (>= 1.72)
rubocop-performance (>= 1.24)
rubocop-rails (>= 2.30)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.13.0)
securerandom (0.4.1)
solid_cable (3.0.12)
@ -277,13 +298,6 @@ GEM
fugit (~> 1.11)
railties (>= 7.1)
thor (>= 1.3.1)
sqlite3 (2.9.4-aarch64-linux-gnu)
sqlite3 (2.9.4-aarch64-linux-musl)
sqlite3 (2.9.4-arm-linux-gnu)
sqlite3 (2.9.4-arm-linux-musl)
sqlite3 (2.9.4-arm64-darwin)
sqlite3 (2.9.4-x86_64-linux-gnu)
sqlite3 (2.9.4-x86_64-linux-musl)
sshkit (1.25.0)
base64
logger
@ -324,17 +338,20 @@ PLATFORMS
x86_64-linux-musl
DEPENDENCIES
annotaterb
bootsnap
brakeman
debug
dotenv-rails
kamal
pg (~> 1.5)
puma (>= 5.0)
rails (~> 8.0.4)
rails-erd
rubocop-rails-omakase
solid_cable
solid_cache
solid_queue
sqlite3 (>= 2.1)
thruster
tzinfo-data

View file

@ -1,41 +1,20 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
host: <%= ENV.fetch("DATABASE_HOST", "localhost") %>
port: <%= ENV.fetch("DATABASE_PORT", 5432) %>
username: <%= ENV.fetch("DATABASE_USER", "postgres") %>
password: <%= ENV.fetch("DATABASE_PASSWORD", "password") %>
development:
<<: *default
database: storage/development.sqlite3
database: price_point_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: storage/test.sqlite3
database: price_point_test
# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
primary:
<<: *default
database: storage/production.sqlite3
cache:
<<: *default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default
database: storage/production_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
<<: *default
database: price_point_production

119
db/schema.rb generated Normal file
View file

@ -0,0 +1,119 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_05_17_111138) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.bigint "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "admins", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "password_digest"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admins_on_email", unique: true
end
create_table "chains", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "guests", force: :cascade do |t|
t.string "username"
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "moderation_logs", force: :cascade do |t|
t.string "reason"
t.string "moderatable_type", null: false
t.integer "moderatable_id", null: false
t.integer "admin_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["admin_id"], name: "index_moderation_logs_on_admin_id"
t.index ["moderatable_type", "moderatable_id"], name: "index_moderation_logs_on_moderatable"
end
create_table "price_reports", force: :cascade do |t|
t.decimal "price"
t.decimal "discount_price"
t.integer "upvotes"
t.integer "downvotes"
t.datetime "reported_at"
t.integer "product_id", null: false
t.integer "store_id", null: false
t.integer "guest_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["guest_id"], name: "index_price_reports_on_guest_id"
t.index ["product_id"], name: "index_price_reports_on_product_id"
t.index ["store_id"], name: "index_price_reports_on_store_id"
end
create_table "products", force: :cascade do |t|
t.string "name"
t.string "barcode"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["barcode"], name: "index_products_on_barcode", unique: true
end
create_table "stores", force: :cascade do |t|
t.string "name"
t.float "latitude"
t.float "longitude"
t.integer "chain_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["chain_id"], name: "index_stores_on_chain_id"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "moderation_logs", "admins"
add_foreign_key "price_reports", "guests"
add_foreign_key "price_reports", "products"
add_foreign_key "price_reports", "stores"
add_foreign_key "stores", "chains"
end

13
docker-compose.yml Normal file
View file

@ -0,0 +1,13 @@
services:
db:
image: postgres:17
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:

View file

@ -3,7 +3,3 @@
one:
name: MyString
barcode: MyString
two:
name: MyString
barcode: MyString