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