add bookmark schema
This commit is contained in:
@@ -9,6 +9,19 @@ def add_signature_format():
|
||||
db.execute('ALTER TABLE "users" ADD COLUMN "signature_markup_language" TEXT NOT NULL DEFAULT "babycode"')
|
||||
db.execute('ALTER TABLE "users" ADD COLUMN "signature_format_version" INTEGER DEFAULT NULL')
|
||||
|
||||
def create_default_bookmark_collections():
|
||||
from .constants import PermissionLevel
|
||||
q = """SELECT users.id FROM users
|
||||
LEFT JOIN bookmark_collections bc ON (users.id = bc.user_id AND bc.is_default = TRUE)
|
||||
WHERE bc.id IS NULL and users.permission IS NOT ?"""
|
||||
user_ids_without_default_collection = db.query(q, PermissionLevel.SYSTEM.value)
|
||||
if len(user_ids_without_default_collection) == 0:
|
||||
return
|
||||
|
||||
from .models import BookmarkCollections
|
||||
for user in user_ids_without_default_collection:
|
||||
BookmarkCollections.create_default(user['id'])
|
||||
|
||||
# format: [str|tuple(str, any...)|callable]
|
||||
MIGRATIONS = [
|
||||
migrate_old_avatars,
|
||||
@@ -16,6 +29,7 @@ MIGRATIONS = [
|
||||
'ALTER TABLE "users" ADD COLUMN "invited_by" INTEGER REFERENCES users(id)', # invitation system
|
||||
'ALTER TABLE "post_history" ADD COLUMN "format_version" INTEGER DEFAULT NULL',
|
||||
add_signature_format,
|
||||
create_default_bookmark_collections,
|
||||
]
|
||||
|
||||
def run_migrations():
|
||||
|
||||
Reference in New Issue
Block a user