Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 800 Bytes

migrations.md

File metadata and controls

52 lines (39 loc) · 800 Bytes

Migrations

sqlc will ignore rollback statements when parsing migration SQL files. The following tools are current supported:

goose

-- +goose Up
CREATE TABLE post (
    id    int NOT NULL,
    title text,
    body  text,
    PRIMARY KEY(id)
);

-- +goose Down
DROP TABLE post;
package db

type Post struct {
	ID    int
	Title sql.NullString
	Body  sql.NullString
}

sql-migrate

-- +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;
package db

type People struct {
	ID    int32
}