Skip to content

re-order the migration tools list #3064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
```