Skip to content

Commit 4a996d3

Browse files
Create migrate_add_admin.py
1 parent 5031f31 commit 4a996d3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/migrate_add_admin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from app.main import create_app
2+
from app.models import db, User
3+
4+
app = create_app()
5+
6+
with app.app_context():
7+
# Add is_admin column to existing users
8+
users = User.query.all()
9+
for user in users:
10+
if not hasattr(user, 'is_admin'):
11+
user.is_admin = user.username == 'admin' # Make 'admin' user an admin
12+
13+
db.session.commit()
14+
print("Migration completed. Admin flags added to users.")

0 commit comments

Comments
 (0)