def init_db(self, conn): """ Create the version table and run the base script on an empty database. """ base = self.read_scripts()[0]['fname'] util.create_from_filename(os.path.join(self.upgrade_dir, base))(conn) self.install_versioning(conn)
def _from_to_version(self, conn, from_version, to_version): scripts = self.read_scripts(from_version, to_version) for script in scripts: # script is a dictionary fullname = os.path.join(self.upgrade_dir, script['fname']) if self.echo: sys.stderr.write('\nExecuting %s' % fullname) if script['ext'] == 'py': # Python script with a upgrade(conn) runpy.run_path(fullname)['upgrade'](conn) else: # SQL script util.create_from_filename(fullname)(conn) if scripts: # save the last version self.version = scripts[-1]['version']
def _from_to_version(self, conn, from_version, to_version, db_versions): scripts = self.read_scripts(from_version, to_version, db_versions) for script in scripts: # script is a dictionary fullname = os.path.join(self.upgrade_dir, script['fname']) if self.echo: sys.stderr.write('Executing %s\n' % fullname) if script['ext'] == 'py': # Python script with a upgrade(conn) runpy.run_path(fullname)['upgrade'](conn) self._insert_script(script, conn) else: # SQL script # notice that this prints the file name in case of error util.create_from_filename(fullname)(conn) self._insert_script(script, conn) if scripts: # save the last version self.version = scripts[-1]['version']