Skip to content

Commit

Permalink
docs: Re-order the migration tools list (#3064)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mohammed90 committed Dec 15, 2023
1 parent e36cf3a commit 58f7316
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions docs/howto/ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand Down Expand Up @@ -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
}
```

0 comments on commit 58f7316

Please sign in to comment.