mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
db: Allow DB-specific queries in the migrations
Sometimes we need some DB-specific magic, and marking migrations with `/*PSQL*/` or `/*SQLITE*/` will now give us that.
This commit is contained in:
@@ -35,6 +35,10 @@ class Rewriter(object):
|
|||||||
|
|
||||||
class Sqlite3Rewriter(Rewriter):
|
class Sqlite3Rewriter(Rewriter):
|
||||||
def rewrite_single(self, query):
|
def rewrite_single(self, query):
|
||||||
|
# Replace DB specific queries with a no-op
|
||||||
|
if "/*PSQL*/" in query:
|
||||||
|
return "UPDATE vars SET intval=1 WHERE name='doesnotexist'" # Return a no-op
|
||||||
|
|
||||||
typemapping = {
|
typemapping = {
|
||||||
r'BIGINT': 'INTEGER',
|
r'BIGINT': 'INTEGER',
|
||||||
r'BIGINTEGER': 'INTEGER',
|
r'BIGINTEGER': 'INTEGER',
|
||||||
@@ -51,6 +55,10 @@ class Sqlite3Rewriter(Rewriter):
|
|||||||
|
|
||||||
class PostgresRewriter(Rewriter):
|
class PostgresRewriter(Rewriter):
|
||||||
def rewrite_single(self, q):
|
def rewrite_single(self, q):
|
||||||
|
# Replace DB specific queries with a no-op
|
||||||
|
if "/*SQLITE*/" in q:
|
||||||
|
return "UPDATE vars SET intval=1 WHERE name='doesnotexist'" # Return a no-op
|
||||||
|
|
||||||
# Let's start by replacing any eventual '?' placeholders
|
# Let's start by replacing any eventual '?' placeholders
|
||||||
q2 = ""
|
q2 = ""
|
||||||
count = 1
|
count = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user