Mercurial > kallithea
diff rhodecode/lib/db_manage.py @ 964:84bb5b8b498d beta
changed dev and tests to postgressql for more error proof setup.
Fixed postgresql database wipe
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 27 Jan 2011 21:45:30 +0100 |
parents | 2f83756f3041 |
children | b232a36cc51f |
line wrap: on
line diff
--- a/rhodecode/lib/db_manage.py Wed Jan 26 18:37:42 2011 +0100 +++ b/rhodecode/lib/db_manage.py Thu Jan 27 21:45:30 2011 +0100 @@ -69,12 +69,17 @@ self.db_exists = True if not override: raise Exception('database already exists') + return 'sqlite' + if self.dburi.startswith('postgresql'): + self.db_exists = True + return 'postgresql' + def create_tables(self, override=False): """Create a auth database """ - self.check_for_db(override) + db_type = self.check_for_db(override) if self.db_exists: log.info("database exist and it's going to be destroyed") if self.tests: @@ -84,7 +89,11 @@ if not destroy: sys.exit() if self.db_exists and destroy: - os.remove(jn(self.root, self.dbname)) + if db_type == 'sqlite': + os.remove(jn(self.root, self.dbname)) + if db_type == 'postgresql': + meta.Base.metadata.drop_all() + checkfirst = not override meta.Base.metadata.create_all(checkfirst=checkfirst) log.info('Created tables for %s', self.dbname)