Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 74b374a

Browse files
committed
Database Migration 4
1 parent ccb2552 commit 74b374a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

db/datastore.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from protos import objects
1111
from protos.objects import Listings, Followers, Following
1212
from os.path import join
13-
from db.migrations import migration1, migration2, migration3
13+
from db.migrations import *
1414

1515

1616
class Database(object):
@@ -180,16 +180,19 @@ def _run_migrations(self):
180180
cursor.execute('''PRAGMA user_version''')
181181
version = cursor.fetchone()[0]
182182
conn.close()
183+
183184
if version == 0:
184185
migration1.migrate(self.PATH)
185186
migration2.migrate(self.PATH)
186187
migration3.migrate(self.PATH)
188+
migration4.migrate(self.PATH)
187189
elif version == 1:
188190
migration2.migrate(self.PATH)
189191
migration3.migrate(self.PATH)
192+
migration4.migrate(self.PATH)
190193
elif version == 2:
191194
migration3.migrate(self.PATH)
192-
195+
migration4.migrate(self.PATH)
193196

194197
class HashMap(object):
195198
"""

db/migrations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__author__ = 'chris'
2+
__all__ = ['migration1', 'migration2', 'migration3', 'migration4']

db/migrations/migration4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def migrate(database_path):
6-
print "migrating to db version 3"
6+
print "migrating to db version 4"
77
conn = sqlite3.connect(database_path)
88
conn.text_factory = str
99
cursor = conn.cursor()
@@ -28,6 +28,6 @@ def migrate(database_path):
2828
(follower.guid.encode("hex"), follower.SerializeToString().encode("hex"),))
2929

3030
# update version
31-
cursor.execute('''PRAGMA user_version = 3''')
31+
cursor.execute('''PRAGMA user_version = 4''')
3232
conn.commit()
3333
conn.close()

0 commit comments

Comments
 (0)