Files
xevion.dev/migrations/20260106073535_initial_schema.sql
Xevion b4c708335b 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
2026-01-06 02:07:42 -06:00

36 lines
1.1 KiB
PL/PgSQL

-- 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();