Skip to content

Commit b81c8d6

Browse files
authored
Switch to sqlite (#22)
* Updated project to use sqlite * Edited migrations directly because I fear no man * Updated search functions and tests to work with sqlite * Updated build tools to remove postgres
1 parent 53bd868 commit b81c8d6

29 files changed

+121
-186
lines changed

.env.sample

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/lint_and_test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
- name: Create and populate ENV file
2525
run: |
2626
echo MIX_ENV=test >> .env
27-
echo POSTGRES_HOST=postgres >> .env
28-
echo POSTGRES_USER=postgres >> .env
29-
echo POSTGRES_PASSWORD=postgres >> .env
3027
3128
- name: Pull prebuilt images
3229
run: docker compose pull

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ npm-debug.log
4141
.DS_Store
4242
scratchpad.md
4343
/scratchpad/
44+
45+
# Database files
46+
*.db
47+
*.db-*

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM elixir:latest
33

44
# Install debian packages
55
RUN apt-get update -qq
6-
RUN apt-get install -y inotify-tools postgresql-client ffmpeg \
6+
RUN apt-get install -y inotify-tools ffmpeg \
77
python3 python3-pip python3-setuptools python3-wheel python3-dev
88

99
# Install nodejs

config/config.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ config :pinchflat, PinchflatWeb.Endpoint,
2929
live_view: [signing_salt: "/t5878kO"]
3030

3131
config :pinchflat, Oban,
32+
engine: Oban.Engines.Lite,
3233
repo: Pinchflat.Repo,
3334
# Keep old jobs for 30 days for display in the UI
3435
plugins: [{Oban.Plugins.Pruner, max_age: 30 * 24 * 60 * 60}],

config/dev.exs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ config :pinchflat,
66

77
# Configure your database
88
config :pinchflat, Pinchflat.Repo,
9-
username: System.get_env("POSTGRES_USER"),
10-
password: System.get_env("POSTGRES_PASSWORD"),
11-
hostname: System.get_env("POSTGRES_HOST"),
12-
database: "pinchflat_dev",
13-
stacktrace: true,
9+
database: Path.expand("../priv/repo/pinchflat_dev.db", Path.dirname(__ENV__.file)),
1410
show_sensitive_data_on_connection_error: true,
15-
pool_size: 10
11+
pool_size: 5
1612

1713
# For development, we disable any cache and enable
1814
# debugging and code reloading.

config/runtime.exs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,16 @@ if System.get_env("PHX_SERVER") do
2121
end
2222

2323
if config_env() == :prod do
24-
database_url =
25-
System.get_env("DATABASE_URL") ||
24+
database_path =
25+
System.get_env("DATABASE_PATH") ||
2626
raise """
27-
environment variable DATABASE_URL is missing.
28-
For example: ecto://USER:PASS@HOST/DATABASE
27+
environment variable DATABASE_PATH is missing.
28+
For example: /etc/pinchflat/pinchflat.db
2929
"""
3030

31-
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
32-
3331
config :pinchflat, Pinchflat.Repo,
34-
# ssl: true,
35-
url: database_url,
36-
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
37-
socket_options: maybe_ipv6
32+
database: database_path,
33+
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "5")
3834

3935
# The secret key base is used to sign/encrypt cookies and other secrets.
4036
# A default value is used in config/dev.exs and config/test.exs but you

config/test.exs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ config :pinchflat, Oban, testing: :manual
1414
# to provide built-in test partitioning in CI environment.
1515
# Run `mix help test` for more information.
1616
config :pinchflat, Pinchflat.Repo,
17-
username: System.get_env("POSTGRES_USER"),
18-
password: System.get_env("POSTGRES_PASSWORD"),
19-
hostname: System.get_env("POSTGRES_HOST"),
20-
database: "pinchflat_test#{System.get_env("MIX_TEST_PARTITION")}",
21-
pool: Ecto.Adapters.SQL.Sandbox,
22-
pool_size: 10
17+
database: Path.expand("../priv/repo/pinchflat_test.db", Path.dirname(__ENV__.file)),
18+
pool_size: 5,
19+
pool: Ecto.Adapters.SQL.Sandbox
2320

2421
# We don't run a server during test. If one is required,
2522
# you can enable the server option below.

docker-compose.ci.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
version: '3'
22
services:
3-
postgres:
4-
image: 'postgres:16-alpine'
5-
environment:
6-
POSTGRES_USER: postgres
7-
POSTGRES_PASSWORD: postgres
8-
93
phx:
104
build: .
115
volumes:
126
- '.:/app'
137
ports:
148
- '4008:4008'
159
command: tail -F /dev/null
16-
env_file: .env

docker-compose.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
version: '3'
22
services:
3-
postgres:
4-
image: 'postgres:16-alpine'
5-
environment:
6-
POSTGRES_USER: postgres
7-
POSTGRES_PASSWORD: postgres
8-
93
phx:
104
build: .
115
volumes:
126
- '.:/app'
137
ports:
148
- '4008:4008'
15-
depends_on:
16-
- postgres
179
command:
1810
- ./docker-run.sh
1911
stdin_open: true
2012
tty: true
21-
env_file:
22-
- .env

0 commit comments

Comments
 (0)