Show More
@@ -41,20 +41,22 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 | if self.dburi.startswith('sqlite'): | |
|
56 | 57 | log.info('checking for existing db in %s', db_path) |
|
57 | 58 | if os.path.isfile(db_path): |
|
59 | ||
|
58 | 60 | self.db_exists = True |
|
59 | 61 | if not override: |
|
60 | 62 | raise Exception('database already exists') |
@@ -8,9 +8,8 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() |
General Comments 0
You need to be logged in to leave comments.
Login now