Skip to content

Commit 1567c9e

Browse files
committed
feat(atlas): bootstrap example migration setup
Signed-off-by: Theo Bob Massard <tbobm@protonmail.com>
1 parent b28e98a commit 1567c9e

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

atlas.hcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
env "local" {
2+
url = "postgres://user:pass@db:5432/local_db?sslmode=disable"
3+
4+
migration {
5+
dir = "file://migrations"
6+
format = "golang-migrate"
7+
}
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- modify: add 'published_at' to papers
2+
ALTER TABLE papers
3+
ADD COLUMN published_at TIMESTAMP;

schema/schema.hcl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
schema "public" {
2+
charset = "UTF8"
3+
collate = "en_US.utf8"
4+
}
5+
6+
table "papers" {
7+
schema = schema.public
8+
column "id" {
9+
type = serial
10+
primary_key = true
11+
}
12+
column "title" {
13+
type = varchar(255)
14+
null = false
15+
}
16+
}
17+
18+
table "mentions" {
19+
schema = schema.public
20+
column "id" {
21+
type = serial
22+
primary_key = true
23+
}
24+
column "paper_id" {
25+
type = int
26+
null = false
27+
}
28+
column "document" {
29+
type = text
30+
null = false
31+
}
32+
33+
foreign_key "mentions_paper_fk" {
34+
columns = [column.paper_id]
35+
ref_table = table.papers
36+
ref_columns = [column.id]
37+
on_delete = "CASCADE"
38+
}
39+
}
40+

0 commit comments

Comments
 (0)