Releases: alexisvisco/amigo
Package name configurable
Default to folder iof migrations and is now configurable
v0.0.15-alpha
Breaking Change Fix: PostgreSQL Dollar-Quoted Functions
Previously, SQL migrations were always split by semicolons, which broke PostgreSQL functions using dollar-quoted strings (
What Changed
| Behavior | Before | After |
|---|---|---|
| Default | Always split by ;
|
Single exec (no splitting) |
| PostgreSQL/SQLite | Broke $$ strings |
Works correctly |
| ClickHouse | Worked | Requires SplitStatements: true
|
New Configuration Option
| Option | Type | Default | Description |
|---|---|---|---|
SplitStatements |
bool | false | When false, entire migration sent as single exec. When true, splits by semicolons respecting annotations. |
Example:
config := amigo.Configuration{
SplitStatements: true, // Enable for ClickHouse
}Annotation Reference
| Annotation | Purpose |
|---|---|
-- amigo:statement:begin |
Start a protected block (no splitting inside) |
-- amigo:statement:end |
End a protected block |
Examples
PostgreSQL Functions (Now Works by Default)
-- migrate:up
CREATE OR REPLACE FUNCTION uuid_generate_v7()
RETURNS uuid AS $$
BEGIN
-- Internal semicolons no longer break the migration
SELECT 1;
SELECT 2;
RETURN gen_random_uuid();
END;
$$ LANGUAGE plpgsql;
-- migrate:down
DROP FUNCTION IF EXISTS uuid_generate_v7();ClickHouse with Protected Blocks
For ClickHouse users who need statement splitting, enable it and use annotations to protect complex statements:
config := amigo.Configuration{
SplitStatements: true, // Required for ClickHouse
}-- migrate:up
CREATE TABLE foo (id UInt64) ENGINE = MergeTree();
-- amigo:statement:begin
CREATE FUNCTION myFunc AS (x) -> multiIf(
x = 1, 'one;',
x = 2, 'two;',
'other'
);
-- amigo:statement:end
CREATE TABLE bar (id UInt64) ENGINE = MergeTree();
-- migrate:down
DROP TABLE bar;
DROP FUNCTION myFunc;
DROP TABLE foo;Migration Guide
| Database | Action Required |
|---|---|
| PostgreSQL | None - works by default |
| SQLite | None - works by default |
| ClickHouse | Add SplitStatements: true to configuration |
v0.0.14-alpha
Remove active record like thing, focus on migration in go and sql, with multi database support and no extra dependencies.
v0.0.13-alpha release
Breaking change :
- better consistency, use main.go generated for the whole cli
- better support for unsuported drivers
- change config to contexts.yml, better support for multiple db with the cli
v0.0.12-alpha
BREAKING CHANGE: migrations are now in db/migrations.
- better logging support
- possibility to migrate using schema.sql (for fresh installs)
- dump the schema via amigo schema
- dump the schema via migrate/rollback cmd (-d flag)
- update documentation
v0.0.11-alpha
- BREAKING CHANGE: default amigo folder is now inside migrations/db
- feature: Query with auto closing of rows
v0.0.10-alpha
refactor: better errors
v0.0.9-alpha
BREAKING CHANGE: changing the id column to version in the table mig_schema_migrations
v0.0.8-alpha
feature: add raw sql support
v0.0.7-alpha
- support unknown dsn