velocious 1.0.54 → 1.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.54",
6
+ "version": "1.0.55",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
@@ -17,7 +17,8 @@ export default new Configuration({
17
17
  host: "mariadb",
18
18
  username: "username",
19
19
  password: "password",
20
- database: "velocious_development"
20
+ database: "velocious_development",
21
+ migrations: true
21
22
  }
22
23
  },
23
24
  production: {
@@ -28,7 +29,8 @@ export default new Configuration({
28
29
  host: "mariadb",
29
30
  username: "username",
30
31
  password: "password",
31
- database: "velocious_production"
32
+ database: "velocious_production",
33
+ migrations: true
32
34
  }
33
35
  },
34
36
  test: {
@@ -39,7 +41,8 @@ export default new Configuration({
39
41
  host: "mariadb",
40
42
  username: "username",
41
43
  password: "password",
42
- database: "velocious_test"
44
+ database: "velocious_test",
45
+ migrations: true
43
46
  }
44
47
  }
45
48
  },
@@ -19,7 +19,8 @@ export default new Configuration({
19
19
  username: "peakflow",
20
20
  password: "password",
21
21
  database: "velocious_test",
22
- useDatabase: "velocious_test"
22
+ useDatabase: "velocious_test",
23
+ migrations: true
23
24
  },
24
25
  mssql: {
25
26
  driver: MssqlDriver,
@@ -27,6 +28,7 @@ export default new Configuration({
27
28
  type: "mssql",
28
29
  database: "velocious_test",
29
30
  useDatabase: "default",
31
+ migrations: true,
30
32
  sqlConfig: {
31
33
  user: "sa",
32
34
  password: "Super-Secret-Password",
@@ -16,6 +16,7 @@ export default new Configuration({
16
16
  type: "mssql",
17
17
  database: "velocious_test",
18
18
  useDatabase: "default",
19
+ migrations: true,
19
20
  sqlConfig: {
20
21
  user: "sa",
21
22
  password: "Super-Secret-Password",
@@ -33,6 +34,7 @@ export default new Configuration({
33
34
  type: "mssql",
34
35
  database: "velocious_test",
35
36
  useDatabase: "default",
37
+ migrations: true,
36
38
  sqlConfig: {
37
39
  user: "sa",
38
40
  password: "Super-Secret-Password",
@@ -19,7 +19,8 @@ export default new Configuration({
19
19
  username: "peakflow",
20
20
  password: "password",
21
21
  database: "velocious_test",
22
- useDatabase: "velocious_test"
22
+ useDatabase: "velocious_test",
23
+ migrations: true
23
24
  },
24
25
  mssql: {
25
26
  driver: MssqlDriver,
@@ -27,6 +28,7 @@ export default new Configuration({
27
28
  type: "mssql",
28
29
  database: "velocious_test",
29
30
  useDatabase: "default",
31
+ migrations: true,
30
32
  sqlConfig: {
31
33
  user: "sa",
32
34
  password: "Super-Secret-Password",
@@ -16,7 +16,8 @@ export default new Configuration({
16
16
  driver: SqliteDriver,
17
17
  poolType: SingleMultiUsePool,
18
18
  type: "sqlite",
19
- name: "test-db"
19
+ name: "test-db",
20
+ migrations: true
20
21
  },
21
22
  mssql: {
22
23
  driver: MssqlDriver,
@@ -24,6 +25,7 @@ export default new Configuration({
24
25
  type: "mssql",
25
26
  database: "velocious_test",
26
27
  useDatabase: "default",
28
+ migrations: true,
27
29
  sqlConfig: {
28
30
  user: "sa",
29
31
  password: "Super-Secret-Password",
@@ -17,8 +17,19 @@ export default class VelociousDatabaseMigrator {
17
17
  async createMigrationsTable() {
18
18
  const dbs = await this.configuration.getCurrentConnections()
19
19
 
20
- for (const db of Object.values(dbs)) {
21
- if (await this.migrationsTableExist(db)) continue
20
+ for (const dbIdentifier in dbs) {
21
+ const db = dbs[dbIdentifier]
22
+ const databaseConfiguration = this.configuration.getDatabaseIdentifier(dbIdentifier)
23
+
24
+ if (!databaseConfiguration.migrations) {
25
+ this.logger.log(`${dbIdentifier} isn't configured for migrations - skipping creating migrations table for it`)
26
+ continue
27
+ }
28
+
29
+ if (await this.migrationsTableExist(db)) {
30
+ this.logger.log(`${dbIdentifier} migrations table already exists - skipping`)
31
+ continue
32
+ }
22
33
 
23
34
  const schemaMigrationsTable = new TableData("schema_migrations", {ifNotExists: true})
24
35
 
@@ -107,6 +118,18 @@ export default class VelociousDatabaseMigrator {
107
118
 
108
119
  for (const dbIdentifier in dbs) {
109
120
  const db = dbs[dbIdentifier]
121
+ const databaseConfiguration = this.configuration.getDatabaseIdentifier(dbIdentifier)
122
+
123
+ if (!databaseConfiguration.migrations) {
124
+ this.logger.debug(`${dbIdentifier} isn't configured for migrations - skipping loading migrations versions for it`)
125
+ continue
126
+ }
127
+
128
+ if (!await this.migrationsTableExist(db)) {
129
+ this.logger.log(`Migration table does not exist for ${dbIdentifier} - skipping loading migrations versions for it`)
130
+ continue
131
+ }
132
+
110
133
  const rows = await db.select("schema_migrations")
111
134
 
112
135
  this.migrationsVersions[dbIdentifier] = {}
@@ -204,6 +227,13 @@ export default class VelociousDatabaseMigrator {
204
227
  const migrationDatabaseIdentifiers = migrationClass.getDatabaseIdentifiers() || ["default"]
205
228
 
206
229
  for (const dbIdentifier in dbs) {
230
+ const databaseConfiguration = this.configuration.getDatabaseIdentifier(dbIdentifier)
231
+
232
+ if (!databaseConfiguration.migrations) {
233
+ this.logger.debug(`${dbIdentifier} isn't configured for migrations - skipping migration ${digg(migration, "date")}`)
234
+ continue
235
+ }
236
+
207
237
  if (!migrationDatabaseIdentifiers.includes(dbIdentifier)) {
208
238
  this.logger.debug(`${dbIdentifier} shouldn't run migration ${migration.file}`, {migrationDatabaseIdentifiers})
209
239
  continue