Skip to content

Commit 85f10d7

Browse files
authored
remove static variable supportsMigration (#78)
* remove static variable supportsMigration * 2.6.12
1 parent d44655a commit 85f10d7

File tree

3 files changed

+25
-37
lines changed

3 files changed

+25
-37
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@themost/sqlite",
3-
"version": "2.6.11",
3+
"version": "2.6.12",
44
"description": "MOST Web Framework SQLite Adapter",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/SqliteAdapter.js

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -284,82 +284,70 @@ class SqliteAdapter {
284284
waterfall([
285285
//1. Check migrations table existence
286286
function (cb) {
287-
if (SqliteAdapter.supportMigrations) {
288-
cb(null, true);
289-
return;
290-
}
291-
self.table('migrations').exists(function (err, exists) {
287+
void self.table('migrations').exists(function (err, exists) {
292288
if (err) {
293-
cb(err);
294-
return;
289+
return cb(err);
295290
}
296-
cb(null, exists);
291+
return cb(null, exists);
297292
});
298293
},
299294
//2. Create migrations table, if it does not exist
300295
function (arg, cb) {
301296
if (arg) {
302-
cb(null, 0);
303-
return;
297+
return cb(null, 0);
304298
}
305299
//create migrations table
306-
self.execute('CREATE TABLE migrations("id" INTEGER PRIMARY KEY AUTOINCREMENT, ' +
300+
void self.execute('CREATE TABLE migrations("id" INTEGER PRIMARY KEY AUTOINCREMENT, ' +
307301
'"appliesTo" TEXT NOT NULL, "model" TEXT NULL, "description" TEXT,"version" TEXT NOT NULL)', [], function (err) {
308-
if (err) {
309-
cb(err);
310-
return;
311-
}
312-
SqliteAdapter.supportMigrations = true;
313-
cb(null, 0);
314-
});
302+
if (err) {
303+
return cb(err);
304+
}
305+
return cb(null, 0);
306+
});
315307
},
316308
//3. Check if migration has already been applied (true=Table version is equal to migration version, false=Table version is older from migration version)
317309
function (arg, cb) {
318-
self.table(migration.appliesTo).version(function (err, version) {
310+
void self.table(migration.appliesTo).version(function (err, version) {
319311
if (err) {
320-
cb(err);
321-
return;
312+
return cb(err);
322313
}
323-
cb(null, (version >= migration.version));
314+
return cb(null, (version >= migration.version));
324315
});
325316
},
326317
//4a. Check table existence (-1=Migration has already been applied, 0=Table does not exist, 1=Table exists)
327318
function (arg, cb) {
328319
//migration has already been applied (set migration.updated=true)
329320
if (arg) {
330321
migration.updated = true;
331-
cb(null, -1);
322+
return cb(null, -1);
332323
}
333324
else {
334-
self.table(migration.appliesTo).exists(function (err, exists) {
325+
void self.table(migration.appliesTo).exists(function (err, exists) {
335326
if (err) {
336-
cb(err);
337-
return;
327+
return cb(err);
338328
}
339-
cb(null, exists ? 1 : 0);
329+
return cb(null, exists ? 1 : 0);
340330
});
341331
}
342332
},
343333
//4. Get table columns
344334
function (arg, cb) {
345335
//migration has already been applied
346336
if (arg < 0) {
347-
cb(null, [arg, null]);
348-
return;
337+
return cb(null, [arg, null]);
349338
}
350-
self.table(migration.appliesTo).columns(function (err, columns) {
339+
void self.table(migration.appliesTo).columns(function (err, columns) {
351340
if (err) {
352-
cb(err);
353-
return;
341+
return cb(err);
354342
}
355-
cb(null, [arg, columns]);
343+
return cb(null, [arg, columns]);
356344
});
357345
},
358346
//5. Migrate target table (create or alter)
359347
function (args, cb) {
360348
//migration has already been applied (args[0]=-1)
361349
if (args[0] < 0) {
362-
cb(null, args[0]);
350+
return cb(null, args[0]);
363351
}
364352
else if (args[0] === 0) {
365353
//create table

0 commit comments

Comments
 (0)