Skip to content

Commit

Permalink
chore(postgres): indexes adjustment and struct cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shini4i committed Feb 6, 2025
1 parent 52f4e09 commit 7876aae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 0 additions & 5 deletions cmd/argo-watcher/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ type KeycloakConfig struct {
}

type DatabaseConfig struct {
Host string `env:"DB_HOST"`
Port string `env:"DB_PORT" envDefault:"5432"`
Name string `env:"DB_NAME"`
User string `env:"DB_USER"`
Password string `env:"DB_PASSWORD"`
SSLMode string `env:"DB_SSL_MODE" envDefault:"disable"`
TimeZone string `env:"DB_TIMEZONE" envDefault:"UTC"`
DSN string `env:"DB_DSN,expand" envDefault:"host=${DB_HOST} port=${DB_PORT} user=${DB_USER} password=${DB_PASSWORD} dbname=${DB_NAME} sslmode=${DB_SSL_MODE} TimeZone=${DB_TIMEZONE}"`
Expand Down
9 changes: 9 additions & 0 deletions db/migrations/000004_optimize_indexes.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Restore the old index on `created`
CREATE INDEX IF NOT EXISTS tasks_idx_created ON tasks (created);

-- Restore the index on `status`
CREATE INDEX IF NOT EXISTS "idx_tasks_status" ON "tasks" ("status");

-- Drop the newly created indexes
DROP INDEX IF EXISTS idx_tasks_created_app;
DROP INDEX IF EXISTS idx_tasks_id;
6 changes: 6 additions & 0 deletions db/migrations/000004_optimize_indexes.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE INDEX IF NOT EXISTS idx_tasks_created_app ON tasks (created DESC, app);
CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_id ON tasks (id);

-- Drop indexes that are no longer needed
DROP INDEX IF EXISTS tasks_idx_created;
DROP INDEX IF EXISTS idx_tasks_status;

0 comments on commit 7876aae

Please sign in to comment.