-
In some case, I prefer using Raw sql to perform migrations, for ex:
Is there a way to do raw sql migrations in emmett? |
Beta Was this translation helpful? Give feedback.
Answered by
gi0baro
Jun 9, 2021
Replies: 1 comment
-
@a0nguyen you can generate an empty migration as described in the docs using the relative command
then you can use the def up(self):
# runs when migration is applied
self.db.executesql("ALTER TABLE ...")
def down(self):
# runs when downgraded to previous
self.db.executesql("ALTER TABLE...") you can also avoid to write |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
a0nguyen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@a0nguyen you can generate an empty migration as described in the docs using the relative command
then you can use the
executesql
command to run whatever SQL query you prefer in the migrationup
anddown
methods, eg:you can also avoid to write
down
commands, but ensure to raise some error so it's clear migration cannot be downgraded.