Skip to content

Commit

Permalink
fix db migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
kricha committed Jan 29, 2018
1 parent 0bb900e commit 3e69f80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions insta_browser/db/browser_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ def __create_update_db(self, version):
create_sql = open(os.path.join(self.sql_path, 'sql', 'init.sql'), 'r').read()
db.cursor().executescript(create_sql)
self.db_log('creating new db')
else:
migration_path = os.path.join(self.sql_path, 'sql', 'migrations')
files = [f for f in os.listdir(migration_path) if
os.path.isfile(os.path.join(migration_path, f)) and int(f.replace('.sql', '')) > version[0]]
files.sort(key=str.lower)
for file in files:
migration_sql = open(os.path.join(migration_path, file), 'r').read()
db.cursor().executescript(migration_sql)
self.db_log('migrate to {}'.format(file))
db.cursor().execute("UPDATE db_version SET version={};".format(file.replace('.sql', '')))
version = (0,)

migration_path = os.path.join(self.sql_path, 'sql', 'migrations')
files = [f for f in os.listdir(migration_path) if
os.path.isfile(os.path.join(migration_path, f)) and int(f.replace('.sql', '')) > version[0]]
files.sort(key=str.lower)
for file in files:
migration_sql = open(os.path.join(migration_path, file), 'r').read()
db.cursor().executescript(migration_sql)
self.db_log('migrate to {}'.format(file))
db.cursor().execute("UPDATE db_version SET version={};".format(file.replace('.sql', '')))

def get_user_counters(self, login):
result = {'updated_at': (datetime.date.today() + datetime.timedelta(days=-40)).strftime("%Y-%m-%d")}
Expand Down
2 changes: 1 addition & 1 deletion insta_browser/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.8.4.1'
__version__ = '0.8.4.2'

0 comments on commit 3e69f80

Please sign in to comment.