fix(migration): use random() on sqlite
This commit is contained in:
parent
c013fe72e6
commit
1d7a8ce1a0
1 changed files with 3 additions and 1 deletions
|
@ -17,12 +17,14 @@ depends_on = None
|
|||
|
||||
def upgrade():
|
||||
if op.get_context().dialect.name == 'postgresql':
|
||||
random_string = "md5(to_char(NOW(), 'YYYY-MM-DD HH24:MI:SS.US'))"
|
||||
on_conflict = " ON CONFLICT (id) DO NOTHING"
|
||||
else:
|
||||
random_string = "CAST(RANDOM() AS TEXT)"
|
||||
on_conflict = ""
|
||||
sql = text(f"""INSERT INTO pool VALUES (
|
||||
-1, 'Hot spares (reserve)', NOW(), NOW(), NULL, 'hotspare',
|
||||
md5(to_char(NOW(), 'YYYY-MM-DD HH24:MI:SS.US')), NULL){on_conflict};""")
|
||||
{random_string}, NULL){on_conflict};""")
|
||||
op.execute(sql)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue