mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
Fix: move the groups creation to init function
This commit is contained in:
@@ -66,9 +66,10 @@ def check_settings():
|
||||
@database_manager.command
|
||||
def create_tables():
|
||||
"""Creates the database tables."""
|
||||
from redash.models import create_db
|
||||
from redash.models import create_db, init_db
|
||||
|
||||
create_db(True, False)
|
||||
init_db()
|
||||
|
||||
@database_manager.command
|
||||
def drop_tables():
|
||||
|
||||
@@ -399,6 +399,10 @@ class Widget(BaseModel):
|
||||
|
||||
all_models = (DataSource, User, QueryResult, Query, Dashboard, Visualization, Widget, ActivityLog, Group)
|
||||
|
||||
def init_db():
|
||||
Group.insert(name='admin', permissions=['admin'], tables=['*']).execute()
|
||||
Group.insert(name='api', permissions=['view_query'], tables=['*']).execute()
|
||||
Group.insert(name='default', permissions=Group.DEFAULT_PERMISSIONS, tables=['*']).execute()
|
||||
|
||||
def create_db(create_tables, drop_tables):
|
||||
db.connect_db()
|
||||
@@ -412,9 +416,4 @@ def create_db(create_tables, drop_tables):
|
||||
if create_tables and not model.table_exists():
|
||||
model.create_table()
|
||||
|
||||
|
||||
Group.insert(name='admin', permissions=['admin'], tables=['*']).execute()
|
||||
Group.insert(name='api', permissions=['view_query'], tables=['*']).execute()
|
||||
Group.insert(name='default', permissions=Group.DEFAULT_PERMISSIONS, tables=['*']).execute()
|
||||
|
||||
db.close_db(None)
|
||||
Reference in New Issue
Block a user