This issue tracks the core tasks for building the MVP of atern — a schema migration tool that compares actual database dumps with migration definitions and generates PostgreSQL, MySQL, MariaDB, and SQLite-compatible SQL statements to bridge the difference.
Goal
The MVP should be a tool that
- Parses SQL/PSQL schemas (starting with
CREATE TABLE)
- Constructs dialect-agnostic Abstract Syntax Trees (ASTs)
- Computes diffs between two versions of a schema (e.g., dump vs. migration file)
- Generates dialect-specific SQL migration statements from the diff
Example
Given a dump:
CREATE TABLE xxx (
id INTEGER AUTOINCREMENT PRIMARY KEY
);
And a migration file:
CREATE TABLE xxx (
id INTEGER AUTOINCREMENT PRIMARY KEY,
name VARCHAR(250) NOT NULL
);
atern should generate:
ALTER TABLE xxx
ADD COLUMN name VARCHAR(255) NOT NULL;
MVP Task Overview
This issue serves as the meta-tracker. Each task is split into its own issue with detailed implementation notes and acceptance criteria.
This issue tracks the core tasks for building the MVP of atern — a schema migration tool that compares actual database dumps with migration definitions and generates PostgreSQL, MySQL, MariaDB, and SQLite-compatible SQL statements to bridge the difference.
Goal
The MVP should be a tool that
CREATE TABLE)Example
Given a dump:
And a migration file:
atern should generate:
MVP Task Overview
Build a Generic AST Builder
Create a reusable, extensible AST layer to represent SQL structures across dialects (tables, columns, constraints, etc.).
Implement
CREATE TABLEParserParse
CREATE TABLEdefinitions from at least one dialect (e.g., MySQL or SQLite) into a structured format.Construct AST from Parsed Components
Convert parsed output into structured AST nodes, representing the full table definition.
Develop Tree Diffing Algorithm
Compute differences between the dump's AST and the migration AST. Output a forest representing add/remove/modify operations.
Convert Forest to SQL Migration Queries
Transform diff results into valid SQL
ALTER TABLEor DDL statements compatible with each target dialect.Write Comprehensive Tests
Ensure correctness through:
This issue serves as the meta-tracker. Each task is split into its own issue with detailed implementation notes and acceptance criteria.