Skip to content

Commit

Permalink
Add Timestamps() macro when generating fizz migrations (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m authored Mar 18, 2019
1 parent af5280b commit 7ba6947
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions migrations/20181104135255_users.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ create_table("users") {
t.Column("bio", "text", {"null": true})
t.Column("price", "numeric", {"null": true, "default": "1.00"})
t.Column("email", "string", {"default": "[email protected]", "size": 50})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135526_good_friends.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create_table("good_friends") {
t.Column("id", "int", {primary: true})
t.Column("first_name", "string", {})
t.Column("last_name", "string", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135627_validatable_cars.up.fizz
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
create_table("validatable_cars") {
t.Column("id", "int", {primary: true})
t.Column("name", "string", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135710_not_validatable_cars.up.fizz
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
create_table("not_validatable_cars") {
t.Column("id", "int", {primary: true})
t.Column("name", "string", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135800_callbacks_users.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ create_table("callbacks_users") {
t.Column("after_u", "string", {})
t.Column("after_d", "string", {})
t.Column("after_f", "string", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135829_books.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ create_table("books") {
t.Column("title", "string", {})
t.Column("user_id", "int", {"null": true})
t.Column("isbn", "string", {"size": 50})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104135856_taxis.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create_table("taxis") {
t.Column("id", "int", {primary: true})
t.Column("model", "string", {})
t.Column("user_id", "int", {"null": true})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140055_songs.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ create_table("songs") {
t.Column("u_id", "int", {"null":true})
t.Column("title", "string", {})
t.Column("composed_by_id", "int", {"null":true})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140142_composers.up.fizz
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
create_table("composers") {
t.Column("id", "int", {primary: true})
t.Column("name", "string", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140221_writers.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create_table("writers") {
t.Column("id", "int", {primary: true})
t.Column("name", "string", {})
t.Column("book_id", "int", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140340_addresses.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create_table("addresses") {
t.Column("id", "int", {primary: true})
t.Column("street", "string", {})
t.Column("house_number", "int", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140431_users_addresses.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create_table("users_addresses") {
t.Column("id", "int", {primary: true})
t.Column("user_id", "int", {})
t.Column("address_id", "int", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140522_courses.up.fizz
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
create_table("courses") {
t.Column("id", "uuid", {"primary": true})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140606_course_codes.up.fizz
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
create_table("course_codes") {
t.Column("id", "uuid", {"primary": true})
t.Column("course_id", "uuid", {})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20181104140743_cakes.up.fizz
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
t.Column("int_slice", "int[]", {"null": true})
t.Column("float_slice", "numeric[]", {"null": true})
t.Column("string_slice", "varchar[]", {"null": true})
t.Timestamps()
}
{{ end -}}
1 change: 1 addition & 0 deletions migrations/20190219210052_students.up.fizz
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
create_table("students") {
t.Column("id", "uuid", {"primary": true})
t.Timestamps()
}
1 change: 1 addition & 0 deletions migrations/20190219210059_parents.up.fizz
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
create_table("parents") {
t.Column("id", "uuid", {"primary": true})
t.Timestamps()
}
1 change: 1 addition & 0 deletions soda/cmd/generate/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (m model) Fizz() string {
s = append(s, "\t"+col.String())
}
}
s = append(s, "\tt.Timestamps()")
s = append(s, "}")
return strings.Join(s, "\n")
}
Expand Down
1 change: 1 addition & 0 deletions soda/cmd/generate/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func Test_model_Fizz(t *testing.T) {
t.Column("id", "integer", {primary: true})
t.Column("brand", "string", {})
t.Column("owner", "string", {null: true})
t.Timestamps()
}`
r.Equal(expected, m.Fizz())
}
Expand Down

0 comments on commit 7ba6947

Please sign in to comment.