Skip to content

Commit

Permalink
Create Index If Not Exists
Browse files Browse the repository at this point in the history
  • Loading branch information
LichtBuch committed Nov 22, 2023
1 parent 0994e31 commit 88d913e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/norm/sqlite.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ proc createTables*[T: Model](dbConn; obj: T) =
dbConn.exec(sql qry)

for index, cols in indexes.pairs:
let qry = "CREATE INDEX $# ON $#($#);" % [index, T.table, cols.join(", ")]
let qry = "CREATE INDEX IF NOT EXISTS $# ON $#($#);" % [index, T.table, cols.join(", ")]

log(qry)

dbConn.exec(sql qry)

for index, cols in uniqueIndexes.pairs:
let qry = "CREATE UNIQUE INDEX $# ON $#($#);" % [index, T.table, cols.join(", ")]
let qry = "CREATE UNIQUE INDEX IF NOT EXISTS $# ON $#($#);" % [index, T.table, cols.join(", ")]

log(qry)

Expand Down

0 comments on commit 88d913e

Please sign in to comment.