1
1
import { sql } from "drizzle-orm" ;
2
- import { integer , sqliteTable , text } from "drizzle-orm/sqlite-core" ;
2
+ import { integer , sqliteTable , text , unique } from "drizzle-orm/sqlite-core" ;
3
3
import { INTENT_STATUS } from "../constants" ;
4
4
5
5
const nowMs = sql `(strftime('%s','now') * 1000)` ;
@@ -13,16 +13,20 @@ export const projects = sqliteTable("projects", {
13
13
. default ( nowMs ) ,
14
14
} ) ;
15
15
16
- export const branches = sqliteTable ( "branches" , {
17
- id : text ( "id" ) . primaryKey ( ) ,
18
- projectId : text ( "project_id" )
19
- . notNull ( )
20
- . references ( ( ) => projects . id ) ,
21
- name : text ( "name" ) . notNull ( ) ,
22
- createdAt : integer ( "created_at" , { mode : "timestamp_ms" } )
23
- . notNull ( )
24
- . default ( nowMs ) ,
25
- } ) ;
16
+ export const branches = sqliteTable (
17
+ "branches" ,
18
+ {
19
+ id : text ( "id" ) . primaryKey ( ) ,
20
+ projectId : text ( "project_id" )
21
+ . notNull ( )
22
+ . references ( ( ) => projects . id ) ,
23
+ name : text ( "name" ) . notNull ( ) ,
24
+ createdAt : integer ( "created_at" , { mode : "timestamp_ms" } )
25
+ . notNull ( )
26
+ . default ( nowMs ) ,
27
+ } ,
28
+ ( table ) => [ unique ( "unq_branch_project" ) . on ( table . name , table . projectId ) ] ,
29
+ ) ;
26
30
27
31
export const intents = sqliteTable ( "intents" , {
28
32
id : integer ( "id" ) . primaryKey ( { autoIncrement : true } ) ,
0 commit comments