@@ -44,23 +44,6 @@ def connection_build():
44
44
return conn , cur
45
45
46
46
47
- def versioning (self ):
48
- """
49
- Run mirgations with respect to versions
50
- """
51
- def wrapper (* args ):
52
- """
53
- Run SQL and mocking DB for versions
54
- """
55
- self = args [0 ]
56
- func_name = func .__name__
57
- version = func_name .rsplit ('_' , 1 )[- 1 ]
58
- self .run_migrations (version )
59
- return func (* args ) # <-- use (self, ...)
60
- func = self
61
- return wrapper
62
-
63
-
64
47
class UpgradeDB (object ):
65
48
"""
66
49
Upgrade Db with respect to versions
@@ -110,17 +93,6 @@ def run_migrations(self, file_name):
110
93
'ERROR trying to create database file (message.dat). Error message: %s\n ' % str (err ))
111
94
os ._exit (0 )
112
95
113
- # @versioning
114
- # def upgrade_schema_data_1(self): # pylint: disable=Method-could-be-a-function, R0201
115
- # """inventory
116
- # For version 1 and 3
117
- # Add a new column to the inventory table to store tags.
118
- # """
119
- #
120
- # logger.debug(
121
- # 'In messages.dat database, adding tag field to'
122
- # ' the inventory table.')
123
-
124
96
def upgrade_to_latest (self , cur , conn ):
125
97
"""
126
98
Initialise upgrade level
@@ -134,6 +106,8 @@ def upgrade_to_latest(self, cur, conn):
134
106
135
107
# call upgrading level in loop
136
108
for l in range (self .current_level , self .max_level ):
109
+ if int (l ) == 3 :
110
+ continue
137
111
self .upgrade_one_level (l )
138
112
self .run_migrations (l )
139
113
@@ -145,126 +119,6 @@ def upgrade_schema_data_level(self, level):
145
119
parameters = (level + 1 ,)
146
120
self .cur .execute (item , parameters )
147
121
148
- # @versioning
149
- # def upgrade_schema_data_2(self): # pylint: disable=Method-could-be-a-function, R0201
150
- # """
151
- # For version 2
152
- # Let's get rid of the first20bytesofencryptedmessage field in the inventory table.
153
- # """
154
- #
155
- # logger.debug(
156
- # 'In messages.dat database, removing an obsolete field from'
157
- # ' the inventory table.')
158
- #
159
- # def upgrade_schema_data_3(self): # pylint: disable=Method-could-be-a-function, R0201
160
- # """
161
- # For version 3
162
- # Call method for version 1
163
- # """
164
- #
165
- # self.upgrade_schema_data_1()
166
- #
167
- # @versioning
168
- # def upgrade_schema_data_4(self): # pylint: disable=Method-could-be-a-function, R0201
169
- # """
170
- # For version 4
171
- # Add a new column to the pubkeys table to store the address version.
172
- # We're going to trash all of our pubkeys and let them be redownloaded.
173
- # """
174
- #
175
- # @versioning
176
- # def upgrade_schema_data_5(self): # pylint: disable=Method-could-be-a-function, R0201
177
- # """
178
- # For version 5
179
- # Add a new table: objectprocessorqueue with which to hold objects
180
- # That have yet to be processed if the user shuts down Bitmessage.
181
- # """
182
- #
183
- # @versioning
184
- # def upgrade_schema_data_6(self): # pylint: disable=Method-could-be-a-function, R0201
185
- # """
186
- # For version 6
187
- # Changes related to protocol v3
188
- # In table inventory and objectprocessorqueue, objecttype is now
189
- # an integer (it was a human-friendly string previously)
190
- # """
191
- #
192
- # logger.debug(
193
- # 'In messages.dat database, dropping and recreating'
194
- # ' the inventory table.')
195
- #
196
- # logger.debug(
197
- # 'Finished dropping and recreating the inventory table.')
198
- #
199
- # @versioning
200
- # def upgrade_schema_data_7(self): # pylint: disable=Method-could-be-a-function, R0201
201
- # """
202
- # For version 7
203
- # The format of data stored in the pubkeys table has changed. Let's
204
- # clear it, and the pubkeys from inventory, so that they'll
205
- # be re-downloaded.
206
- # """
207
- #
208
- # logger.debug(
209
- # 'In messages.dat database, clearing pubkeys table'
210
- # ' because the data format has been updated.')
211
- #
212
- # logger.debug('Finished clearing currently held pubkeys.')
213
- #
214
- # @versioning
215
- # def upgrade_schema_data_8(self): # pylint: disable=Method-could-be-a-function, R0201
216
- # """
217
- # For version 8
218
- # Add a new column to the inbox table to store the hash of
219
- # the message signature. We'll use this as temporary message UUID
220
- # in order to detect duplicates.
221
- # """
222
- #
223
- # logger.debug(
224
- # 'In messages.dat database, adding sighash field to'
225
- # ' the inbox table.')
226
- #
227
- # @versioning
228
- # def upgrade_schema_data_9(self): # pylint: disable=Method-could-be-a-function, R0201
229
- # """
230
- # For version 9
231
- # We'll also need a `sleeptill` field and a `ttl` field. Also we
232
- # can combine the pubkeyretrynumber and msgretrynumber into one.
233
- # """
234
- #
235
- # logger.info(
236
- # 'In messages.dat database, making TTL-related changes:'
237
- # ' combining the pubkeyretrynumber and msgretrynumber'
238
- # ' fields into the retrynumber field and adding the'
239
- # ' sleeptill and ttl fields...')
240
- #
241
- # logger.info('In messages.dat database, finished making TTL-related changes.')
242
- # logger.debug('In messages.dat database, adding address field to the pubkeys table.')
243
- #
244
- # # We're going to have to calculate the address for each row in the pubkeys
245
- # # table. Then we can take out the hash field.
246
- # self.cur.execute('''ALTER TABLE pubkeys ADD address text DEFAULT '' ''')
247
- #
248
- # # replica for loop to update hashed address
249
- # self.cur.execute('''UPDATE pubkeys SET address=(enaddr(pubkeys.addressversion, 1, hash)); ''')
250
- #
251
- # self.run_migrations("9_1")
252
- #
253
- # logger.debug(
254
- # 'In messages.dat database, done adding address field to the pubkeys table'
255
- # ' and removing the hash field.')
256
- #
257
- # @versioning
258
- # def upgrade_schema_data_10(self): # pylint: disable=Method-could-be-a-function, R0201
259
- # """
260
- # For version 10
261
- # Update the address colunm to unique in addressbook table
262
- # """
263
- #
264
- # logger.debug(
265
- # 'In messages.dat database, updating address column to UNIQUE'
266
- # ' in the addressbook table.')
267
-
268
122
269
123
class sqlThread (threading .Thread , UpgradeDB ):
270
124
"""A thread for all SQL operations"""
0 commit comments