From 58f731633e23eddf47d04c534be3ec053e2d6c8f Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sat, 16 Dec 2023 01:33:18 +0300 Subject: [PATCH] docs: Re-order the migration tools list (#3064) The list for details about each migration tool didn't match the bullet-point list at the beginning of the section. It's a bit confusing for unsuspecting readers to see an item at position 2 but not find it as the second item in the expanded description. --- docs/howto/ddl.md | 118 +++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/docs/howto/ddl.md b/docs/howto/ddl.md index 4e9d36d855..0b25800365 100644 --- a/docs/howto/ddl.md +++ b/docs/howto/ddl.md @@ -69,66 +69,21 @@ type Post struct { } ``` -### goose - -```sql --- +goose Up -CREATE TABLE post ( - id int NOT NULL, - title text, - body text, - PRIMARY KEY(id) -); - --- +goose Down -DROP TABLE post; -``` - -```go -package db - -type Post struct { - ID int - Title sql.NullString - Body sql.NullString -} -``` - -### sql-migrate +### dbmate ```sql --- +migrate Up --- SQL in section 'Up' is executed when this migration is applied -CREATE TABLE people (id int); - - --- +migrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE people; -``` - -```go -package db - -type People struct { - ID int32 -} -``` - -### tern +-- migrate:up +CREATE TABLE foo (bar INT NOT NULL); -```sql -CREATE TABLE comment (id int NOT NULL, text text NOT NULL); ----- create above / drop below ---- -DROP TABLE comment; +-- migrate:down +DROP TABLE foo; ``` ```go package db -type Comment struct { - ID int32 - Text string +type Foo struct { + Bar int32 } ``` @@ -188,20 +143,65 @@ type Post struct { } ``` -### dbmate +### goose ```sql --- migrate:up -CREATE TABLE foo (bar INT NOT NULL); +-- +goose Up +CREATE TABLE post ( + id int NOT NULL, + title text, + body text, + PRIMARY KEY(id) +); --- migrate:down -DROP TABLE foo; +-- +goose Down +DROP TABLE post; ``` ```go package db -type Foo struct { - Bar int32 +type Post struct { + ID int + Title sql.NullString + Body sql.NullString +} +``` + +### sql-migrate + +```sql +-- +migrate Up +-- SQL in section 'Up' is executed when this migration is applied +CREATE TABLE people (id int); + + +-- +migrate Down +-- SQL section 'Down' is executed when this migration is rolled back +DROP TABLE people; +``` + +```go +package db + +type People struct { + ID int32 +} +``` + +### tern + +```sql +CREATE TABLE comment (id int NOT NULL, text text NOT NULL); +---- create above / drop below ---- +DROP TABLE comment; +``` + +```go +package db + +type Comment struct { + ID int32 + Text string } ```