Show More
@@ -41,23 +41,25 b' import logging' | |||
|
41 | 41 | log = logging.getLogger(__name__) |
|
42 | 42 | |
|
43 | 43 | class DbManage(object): |
|
44 |
def __init__(self, log_sql, db |
|
|
45 |
self.dbname = db |
|
|
44 | def __init__(self, log_sql, dbconf, root, tests=False): | |
|
45 | self.dbname = dbconf.split('/')[-1] | |
|
46 | 46 | self.tests = tests |
|
47 | 47 | self.root = root |
|
48 | dburi = 'sqlite:////%s' % jn(self.root, self.dbname) | |
|
49 | engine = create_engine(dburi, echo=log_sql) | |
|
48 | self.dburi = dbconf | |
|
49 | engine = create_engine(self.dburi, echo=log_sql) | |
|
50 | 50 | init_model(engine) |
|
51 | 51 | self.sa = meta.Session() |
|
52 | 52 | self.db_exists = False |
|
53 | 53 | |
|
54 | 54 | def check_for_db(self, override): |
|
55 | 55 | db_path = jn(self.root, self.dbname) |
|
56 | log.info('checking for existing db in %s', db_path) | |
|
57 | if os.path.isfile(db_path): | |
|
58 | self.db_exists = True | |
|
59 | if not override: | |
|
60 | raise Exception('database already exists') | |
|
56 | if self.dburi.startswith('sqlite'): | |
|
57 | log.info('checking for existing db in %s', db_path) | |
|
58 | if os.path.isfile(db_path): | |
|
59 | ||
|
60 | self.db_exists = True | |
|
61 | if not override: | |
|
62 | raise Exception('database already exists') | |
|
61 | 63 | |
|
62 | 64 | def create_tables(self, override=False): |
|
63 | 65 | """ |
@@ -8,16 +8,15 b' log = logging.getLogger(__name__)' | |||
|
8 | 8 | |
|
9 | 9 | def setup_app(command, conf, vars): |
|
10 | 10 | """Place any commands to setup rhodecode here""" |
|
11 |
db |
|
|
12 |
dbmanage = DbManage(log_sql=True, db |
|
|
13 | tests=False) | |
|
11 | dbconf = conf['sqlalchemy.db1.url'] | |
|
12 | dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=conf['here'], tests=False) | |
|
14 | 13 | dbmanage.create_tables(override=True) |
|
15 | 14 | dbmanage.config_prompt(None) |
|
16 | 15 | dbmanage.create_default_user() |
|
17 | 16 | dbmanage.admin_prompt() |
|
18 | 17 | dbmanage.create_permissions() |
|
19 | 18 | dbmanage.populate_default_permissions() |
|
20 | ||
|
19 | ||
|
21 | 20 | load_environment(conf.global_conf, conf.local_conf, initial=True) |
|
22 | 21 | |
|
23 | 22 |
General Comments 0
You need to be logged in to leave comments.
Login now