feat(01-02): create Flyway migrator service and initial migration

- Add Migrator trait with migrate/status ZIO effects
- Create V1 migration for summer_users table
- Configure Flyway with summer_migrations table and classpath location
- Migrations run manually via CLI, not on startup
This commit is contained in:
Jakub Zych
2026-02-04 22:13:03 +01:00
parent 106e66413e
commit ddb1964d1a
2 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
-- Summer CMS initial schema
-- Creates the base users table for future auth
CREATE TABLE summer_users (
id BIGSERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_summer_users_email ON summer_users(email);
-- Trigger for 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_summer_users_updated_at
BEFORE UPDATE ON summer_users
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();