You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91-79Lines changed: 91 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,100 @@
4
4
5
5
English | [中文](README_zh.md)
6
6
7
-
SQLize is a powerful migration generation tool that detects differences between two SQL state sources. It simplifies migration creation by comparing an existing SQL schema with Go models, ensuring seamless database updates.
7
+
## Purpose
8
8
9
-
Designed for flexibility, SQLize supports `MySQL`, `PostgreSQL`, and `SQLite`and integrates well with popular Go ORM and migration tools like `gorm` (gorm tag), `golang-migrate/migrate` (migration version), and more.
9
+
**SQLize** generates database migrations by comparing two schema sources: your **Go structs** (desired state) and your **existing migrations** (current state). Instead of writing migration SQL by hand, you define models in Go and SQLize produces the `ALTER TABLE`, `CREATE TABLE`, and related statements needed to bring your database up to date.
10
10
11
-
Additionally, SQLize offers advanced features, including `Avro Schema` export (MySQL only) and `ERD` diagram generation (`MermaidJS`).
11
+
### What problem does it solve?
12
+
13
+
-**Manual migrations are error-prone** — Easy to forget columns, indexes, or foreign keys when writing `ALTER TABLE` by hand
14
+
-**Schema drift** — Go models and the database can get out of sync over time
15
+
-**Boilerplate** — Repetitive work creating up/down migrations for every schema change
16
+
17
+
### How it works
18
+
19
+
1.**Desired state** — Load schema from your Go structs (via `FromObjects`)
20
+
2.**Current state** — Load schema from your migration folder (via `FromMigrationFolder`)
21
+
3.**Diff** — SQLize compares them and computes the changes
22
+
4.**Output** — Get migration SQL (`StringUp` / `StringDown`) or write files directly (`WriteFilesWithVersion`)
23
+
24
+
```
25
+
Go structs (desired) ──┐
26
+
├──► Diff ──► Migration SQL (up/down)
27
+
Migration files (current) ─┘
28
+
```
29
+
30
+
## Features
31
+
32
+
-**Multi-database**: MySQL, PostgreSQL, SQLite, SQL Server
33
+
-**ORM-friendly**: Works with struct tags (`sql`, `gorm`), compatible with `golang-migrate/migrate`
0 commit comments