Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dtd
/
go-webserver-boilerplate
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 24556301
authored
Feb 20, 2025
by
mhmdhaekal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migration(initialize): create migration
1 parent
3172c624
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
.env.example
Makefile
migration/postgres/20250219152426_create_user_table.sql
.env.example
0 → 100644
View file @
2455630
DATABASE_URL=
Makefile
View file @
2455630
BINDIR
:=
bin
ifneq
(,$(wildcard
.env))
include
.env
export
endif
BINDIR
:=
bin
APPS
:=
$
(
notdir
$
(
wildcard cmd/
*
))
APPS
:=
$
(
notdir
$
(
wildcard cmd/
*
))
BUILD_TARGETS
:=
$
(
filter-out build clean,
$(MAKECMDGOALS)
)
BUILD_TARGETS
:=
$
(
filter-out build clean,
$(MAKECMDGOALS)
)
.PHONY
:
build clean default
.PHONY
:
build clean default
...
@@ -48,5 +51,21 @@ test:
...
@@ -48,5 +51,21 @@ test:
@
echo
"Running test"
@
echo
"Running test"
@
go
test
./...
@
go
test
./...
migrate-postgres
:
@
if
[
-z
"
$(DATABASE_URL)
"
]
;
then
\
echo
"Error: DATABASE_URL is not set. Please set it in .env or your environment."
;
\
exit
1;
\
fi
;
\
echo
"Running database migrations with goose using driver
$$
driver..."
;
\
goose -dir migration/postgres postgres
"
$(DATABASE_URL)
"
up
migrate-postgres-status
:
@
if
[
-z
"
$(DATABASE_URL)
"
]
;
then
\
echo
"Error: DATABASE_URL is not set. Please set it in .env or your environment."
;
\
exit
1;
\
fi
;
\
echo
"Running migration status with goose using driver
$$
driver..."
;
\
goose -dir migration/postgres postgres
"
$(DATABASE_URL)
"
status
%
:
%
:
@
:
@
:
migration/postgres/20250219152426_create_user_table.sql
0 → 100644
View file @
2455630
-- +goose Up
-- +goose StatementBegin
CREATE
TABLE
"user"
(
"id"
SERIAL
PRIMARY
KEY
,
"IdentityNumber"
VARCHAR
(
255
)
UNIQUE
NOT
NULL
,
"email"
VARCHAR
(
255
)
UNIQUE
NOT
NULL
,
"name"
VARCHAR
(
255
)
NOT
NULL
,
"is_active"
BOOLEAN
NOT
NULL
DEFAULT
FALSE
,
"created_at"
TIMESTAMPTZ
NOT
NULL
DEFAULT
NOW
(),
"updated_at"
TIMESTAMPTZ
NOT
NULL
DEFAULT
NOW
(),
"deleted_at"
TIMESTAMPTZ
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP
TABLE
"user"
;
-- +goose StatementEnd
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment