Skip to content

Commit 344fd78

Browse files
committed
Use directly goose in Makefile
1 parent 56e269f commit 344fd78

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/db/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IMAGE := e2b-orchestration/db-migrator
77
.PHONY: migrate
88
migrate:
99
@echo "Applying Postgres migration *$(notdir $@)*"
10-
POSTGRES_CONNECTION_STRING=$(POSTGRES_CONNECTION_STRING) go run ./scripts/migrator.go
10+
@$(goose) up
1111
@echo "Done"
1212
migrate/up: migrate
1313
migrate/down:

packages/db/migrations/20000101000000_auth.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
-- +goose StatementBegin
33
CREATE SCHEMA IF NOT EXISTS auth;
44

5+
CREATE ROLE authenticated;
6+
7+
CREATE FUNCTION auth.uid() RETURNS uuid AS $func$
8+
BEGIN
9+
RETURN gen_random_uuid();
10+
END;
11+
$func$ LANGUAGE plpgsql;
12+
13+
-- Grant execute on auth.uid() to postgres role
14+
GRANT EXECUTE ON FUNCTION auth.uid() TO postgres;
15+
516
CREATE TABLE auth.users (
617
id uuid NOT NULL DEFAULT gen_random_uuid(),
718
email text NOT NULL,

0 commit comments

Comments
 (0)