Skip to content

Commit 3b47d32

Browse files
committed
use postgresql instead of sqlite3
use postgresql instead of sqlite3
1 parent 9ae64ce commit 3b47d32

File tree

6 files changed

+193
-15
lines changed

6 files changed

+193
-15
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ on:
55
- main
66
jobs:
77
tests:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-24.04
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: Setup FluentCI
1212
uses: fluentci-io/setup-fluentci@v5
13+
with:
14+
wasm: true
15+
plugin: postgres
16+
args: start
1317
env:
1418
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
POSTGRES_USER: postgres
20+
POSTGRES_DB: demo_rails_development
1521
- name: check style + security
1622
run: |
1723
fluentci run --wasm ruby bundle_exec rubocop

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ gem "rails", "~> 7.0.6"
99
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
1010
gem "sprockets-rails"
1111

12-
# Use sqlite3 as the database for Active Record
13-
gem "sqlite3", "~> 1.4"
12+
# Use postgresql as the database for Active Record
13+
gem "pg", "~> 1.1"
1414

1515
# Use the Puma web server [https://github.com/puma/puma]
1616
gem "puma", "~> 5.0"

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ GEM
135135
parser (3.2.2.3)
136136
ast (~> 2.4.1)
137137
racc
138+
pg (1.5.7)
138139
public_suffix (5.0.3)
139140
puma (5.6.6)
140141
nio4r (~> 2.0)
@@ -220,7 +221,6 @@ GEM
220221
actionpack (>= 5.2)
221222
activesupport (>= 5.2)
222223
sprockets (>= 3.0.0)
223-
sqlite3 (1.6.3-x86_64-linux)
224224
stimulus-rails (1.2.1)
225225
railties (>= 6.0.0)
226226
thor (1.2.2)
@@ -260,14 +260,14 @@ DEPENDENCIES
260260
debug
261261
importmap-rails
262262
jbuilder
263+
pg (~> 1.1)
263264
puma (~> 5.0)
264265
rails (~> 7.0.6)
265266
redis (~> 4.0)
266267
rspec-rails (>= 3.9.0)
267268
rubocop
268269
selenium-webdriver
269270
sprockets-rails
270-
sqlite3 (~> 1.4)
271271
stimulus-rails
272272
turbo-rails
273273
tzinfo-data

config/database.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,87 @@
1-
# SQLite. Versions 3.8.0 and up are supported.
2-
# gem install sqlite3
1+
# PostgreSQL. Versions 9.3 and up are supported.
32
#
4-
# Ensure the SQLite 3 gem is defined in your Gemfile
5-
# gem "sqlite3"
3+
# Install the pg driver:
4+
# gem install pg
5+
# On macOS with Homebrew:
6+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7+
# On Windows:
8+
# gem install pg
9+
# Choose the win32 build.
10+
# Install PostgreSQL and put its /bin directory on your path.
11+
#
12+
# Configure Using Gemfile
13+
# gem "pg"
614
#
715
default: &default
8-
adapter: sqlite3
16+
adapter: postgresql
17+
encoding: unicode
18+
# For details on connection pooling, see Rails configuration guide
19+
# https://guides.rubyonrails.org/configuring.html#database-pooling
920
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10-
timeout: 5000
21+
username: postgres
22+
host: localhost
23+
port: 5432
1124

1225
development:
1326
<<: *default
14-
database: db/development.sqlite3
27+
database: demo_rails_development
28+
29+
# The specified database role being used to connect to PostgreSQL.
30+
# To create additional roles in PostgreSQL see `$ createuser --help`.
31+
# When left blank, PostgreSQL will use the default role. This is
32+
# the same name as the operating system user running Rails.
33+
#username: blog
34+
35+
# The password associated with the PostgreSQL role (username).
36+
#password:
37+
38+
# Connect on a TCP socket. Omitted by default since the client uses a
39+
# domain socket that doesn't need configuration. Windows does not have
40+
# domain sockets, so uncomment these lines.
41+
#host: localhost
42+
43+
# The TCP port the server listens on. Defaults to 5432.
44+
# If your server runs on a different port number, change accordingly.
45+
#port: 5432
46+
47+
# Schema search path. The server defaults to $user,public
48+
#schema_search_path: myapp,sharedapp,public
49+
50+
# Minimum log levels, in increasing order:
51+
# debug5, debug4, debug3, debug2, debug1,
52+
# log, notice, warning, error, fatal, and panic
53+
# Defaults to warning.
54+
#min_messages: notice
1555

1656
# Warning: The database defined as "test" will be erased and
1757
# re-generated from your development database when you run "rake".
1858
# Do not set this db to the same as development or production.
1959
test:
2060
<<: *default
21-
database: db/test.sqlite3
61+
database: demo_rails_test
2262

63+
# As with config/credentials.yml, you never want to store sensitive information,
64+
# like your database password, in your source code. If your source code is
65+
# ever seen by anyone, they now have access to your database.
66+
#
67+
# Instead, provide the password or a full connection URL as an environment
68+
# variable when you boot the app. For example:
69+
#
70+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
71+
#
72+
# If the connection URL is provided in the special DATABASE_URL environment
73+
# variable, Rails will automatically merge its configuration values on top of
74+
# the values provided in this file. Alternatively, you can specify a connection
75+
# URL environment variable explicitly:
76+
#
77+
# production:
78+
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
79+
#
80+
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
81+
# for a full overview on how database connection configuration can be specified.
82+
#
2383
production:
2484
<<: *default
25-
database: db/production.sqlite3
85+
database: demo_rails_production
86+
username: postgres
87+
password: <%= ENV["BLOG_DATABASE_PASSWORD"] %>

devbox.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"yarn@latest",
77
"pkg-config@latest",
88
"gcc@latest",
9-
"gnumake@latest"
9+
"gnumake@latest",
10+
"postgresql@latest"
1011
],
1112
"shell": {
1213
"init_hook": [

devbox.lock

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,115 @@
273273
}
274274
}
275275
},
276+
"postgresql@latest": {
277+
"last_modified": "2024-08-21T20:16:49Z",
278+
"plugin_version": "0.0.2",
279+
"resolved": "github:NixOS/nixpkgs/36a9aeaaa17a2d4348498275f9fe530cd4f9e519#postgresql",
280+
"source": "devbox-search",
281+
"version": "16.4",
282+
"systems": {
283+
"aarch64-darwin": {
284+
"outputs": [
285+
{
286+
"name": "out",
287+
"path": "/nix/store/i0asdxabgdls1xnjgd1a5y1fv27nfmfw-postgresql-16.4",
288+
"default": true
289+
},
290+
{
291+
"name": "man",
292+
"path": "/nix/store/mx2n38fqz3y7bbw9i2vccgr1nr53nlhy-postgresql-16.4-man",
293+
"default": true
294+
},
295+
{
296+
"name": "doc",
297+
"path": "/nix/store/8s96kqcqdjxczgqlwjsp5sd293pgfc1m-postgresql-16.4-doc"
298+
},
299+
{
300+
"name": "lib",
301+
"path": "/nix/store/jvc35r9p6y5pv8i7skbmbi120s7jq6ay-postgresql-16.4-lib"
302+
}
303+
],
304+
"store_path": "/nix/store/i0asdxabgdls1xnjgd1a5y1fv27nfmfw-postgresql-16.4"
305+
},
306+
"aarch64-linux": {
307+
"outputs": [
308+
{
309+
"name": "out",
310+
"path": "/nix/store/d1ks0fmlm3jx4zb3zs8ghp973v28p2hi-postgresql-16.4",
311+
"default": true
312+
},
313+
{
314+
"name": "man",
315+
"path": "/nix/store/kvf1yxvm3zsbykm022zhk5xjdsady9c1-postgresql-16.4-man",
316+
"default": true
317+
},
318+
{
319+
"name": "debug",
320+
"path": "/nix/store/mxf4lgspi1c2ag5z3nmr2sd8q6pmssjb-postgresql-16.4-debug"
321+
},
322+
{
323+
"name": "doc",
324+
"path": "/nix/store/f1vyyv54ai0hq553ncm8ahaz5i948ign-postgresql-16.4-doc"
325+
},
326+
{
327+
"name": "lib",
328+
"path": "/nix/store/wbypzrzg1z9yl6cw6n4c2703z9m3dyzl-postgresql-16.4-lib"
329+
}
330+
],
331+
"store_path": "/nix/store/d1ks0fmlm3jx4zb3zs8ghp973v28p2hi-postgresql-16.4"
332+
},
333+
"x86_64-darwin": {
334+
"outputs": [
335+
{
336+
"name": "out",
337+
"path": "/nix/store/fpwv4ygz88bdk9xa3zw9almda756p9x8-postgresql-16.4",
338+
"default": true
339+
},
340+
{
341+
"name": "man",
342+
"path": "/nix/store/yn0kvg33b2c6bkparh2vb74m2fdpszzs-postgresql-16.4-man",
343+
"default": true
344+
},
345+
{
346+
"name": "doc",
347+
"path": "/nix/store/66sbl8q8gl2v6gjck736pg9ay8h68apy-postgresql-16.4-doc"
348+
},
349+
{
350+
"name": "lib",
351+
"path": "/nix/store/qlp9p58ph8i1pjn6cnz0mycq64kid88a-postgresql-16.4-lib"
352+
}
353+
],
354+
"store_path": "/nix/store/fpwv4ygz88bdk9xa3zw9almda756p9x8-postgresql-16.4"
355+
},
356+
"x86_64-linux": {
357+
"outputs": [
358+
{
359+
"name": "out",
360+
"path": "/nix/store/48abcjx52nbp8myygxgwqb4gh4xsg5fa-postgresql-16.4",
361+
"default": true
362+
},
363+
{
364+
"name": "man",
365+
"path": "/nix/store/nskmfhwxkzpn0cb1b69ap46jp9qcdg5p-postgresql-16.4-man",
366+
"default": true
367+
},
368+
{
369+
"name": "debug",
370+
"path": "/nix/store/mwdr7qpyf1ggllcs0f1qgywj3rab14v4-postgresql-16.4-debug"
371+
},
372+
{
373+
"name": "doc",
374+
"path": "/nix/store/vxrd7vs1v3mv70004mrs3070fjl58vrr-postgresql-16.4-doc"
375+
},
376+
{
377+
"name": "lib",
378+
"path": "/nix/store/37l0ff1bqzppalq55g7a5af0fcvg47wy-postgresql-16.4-lib"
379+
}
380+
],
381+
"store_path": "/nix/store/48abcjx52nbp8myygxgwqb4gh4xsg5fa-postgresql-16.4"
382+
}
383+
}
384+
},
276385
"ruby_3_1@latest": {
277386
"last_modified": "2024-05-01T20:12:28Z",
278387
"plugin_version": "0.0.2",

0 commit comments

Comments
 (0)