feat: add PostgreSQL database integration for projects

- Add SQLx with Postgres support and migration system
- Create projects table with status enum and auto-updated timestamps
- Implement database queries and API response conversion layer
- Add Justfile commands for database management and seeding
- Integrate health checks for both Bun and database connectivity
This commit is contained in:
2026-01-06 01:53:49 -06:00
parent 5fc7277cd7
commit b4c708335b
11 changed files with 1235 additions and 90 deletions
@@ -0,0 +1,35 @@
-- Project status enum
CREATE TYPE project_status AS ENUM ('active', 'maintained', 'archived', 'hidden');
-- Projects table
CREATE TABLE projects (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
slug TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
description TEXT NOT NULL,
status project_status NOT NULL DEFAULT 'active',
github_repo TEXT,
demo_url TEXT,
priority INTEGER NOT NULL DEFAULT 0,
icon TEXT,
last_github_activity TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Indexes for common queries
CREATE INDEX idx_projects_status ON projects(status);
CREATE INDEX idx_projects_priority ON projects(priority DESC);
CREATE INDEX idx_projects_slug ON projects(slug);
-- Trigger to auto-update updated_at
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER update_projects_updated_at BEFORE UPDATE ON projects
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();