Skip to content

Commit

Permalink
feat: 🎉 Create migration file for onboarding table
Browse files Browse the repository at this point in the history
  • Loading branch information
albinmedoc committed Jul 30, 2024
1 parent 0634aaf commit 027e665
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# CREATED ON VERSION: V4.1.1
# MIGRATION: 2024-07-30_11-02-04
# CREATED: Tue Jul 30 2024
#

from peewee import *
from playhouse.migrate import *

from app import db

# Do not change the name of this file,
# migrations are run in order of their filenames date and time

def run():
# Use migrator to perform actions on the database
migrator = SqliteMigrator(db)

# Create new table 'onboarding'
with db.transaction():
# Check if the table exists
cursor = db.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='onboarding';")
table_exists = cursor.fetchone()

if not table_exists:
db.execute_sql("""
CREATE TABLE "onboarding" (
"id" INTEGER NOT NULL UNIQUE,
"value" TEXT NOT NULL,
"order" INTEGER NOT NULL UNIQUE,
"enabled" INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY("id")
)
""")
print("Table 'onboarding' created successfully")
else:
print("Table 'onboarding' already exists")

print("Migration 2024-07-30_11-02-04 complete")

0 comments on commit 027e665

Please sign in to comment.