Skip to content

Commit 606541b

Browse files
author
Nap Joseph Calub
committed
feat: update migrate script
1 parent 8b73899 commit 606541b

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

migrations/global/001_20250710_093749_setup_user.surql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DEFINE FIELD email ON user TYPE string
1111
$value != NONE
1212
AND string::is::email($value);
1313
DEFINE FIELD password ON user TYPE string;
14+
DEFINE FIELD created_at ON user TYPE datetime;
1415
DEFINE FIELD enabled ON user TYPE bool;
1516

1617
DEFINE ACCESS user ON DATABASE TYPE RECORD
@@ -19,6 +20,7 @@ DEFINE ACCESS user ON DATABASE TYPE RECORD
1920
name: $name,
2021
email: $email,
2122
password: crypto::argon2::generate($password),
23+
created_at: time::now(),
2224
enabled: true
2325
}
2426
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Migration: create user profile
2+
3+
BEGIN TRANSACTION;
4+
5+
REMOVE TABLE IF EXISTS user_profile;
6+
7+
COMMIT TRANSACTION;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Migration: create user profile
2+
3+
BEGIN TRANSACTION;
4+
5+
DEFINE TABLE user_profile SCHEMALESS;
6+
7+
COMMIT TRANSACTION;

scripts/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async function getTenants(): Promise<string[]> {
207207
config.SURREALDB_GLOBAL_NAMESPACE,
208208
config.SURREALDB_GLOBAL_DATABASE,
209209
);
210-
const tenants = await db.select<{ namespace: string }>("registry");
210+
const tenants = await db.select<{ namespace: string }>("tenant");
211211
return Array.isArray(tenants) ? tenants.map((t) => t.namespace) : [];
212212
}
213213

0 commit comments

Comments
 (0)