-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat-3672-use_query_params_for_filter
- Loading branch information
Showing
8 changed files
with
155 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import fs from "fs"; | ||
const dir = "./db/knex_migrations"; | ||
|
||
// Get the file list (ending with .js) from the directory | ||
const files = fs.readdirSync(dir).filter((file) => file !== "README.md"); | ||
|
||
// They are wrong, but they had been merged, so allowed. | ||
const exceptionList = [ | ||
"2024-08-24-000-add-cache-bust.js", | ||
"2024-10-1315-rabbitmq-monitor.js", | ||
]; | ||
|
||
// Correct format: YYYY-MM-DD-HHmm-description.js | ||
|
||
for (const file of files) { | ||
if (exceptionList.includes(file)) { | ||
continue; | ||
} | ||
|
||
// Check ending with .js | ||
if (!file.endsWith(".js")) { | ||
console.error(`It should end with .js: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
const parts = file.split("-"); | ||
|
||
// Should be at least 5 parts | ||
if (parts.length < 5) { | ||
console.error(`Invalid format: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
// First part should be a year >= 2024 | ||
const year = parseInt(parts[0], 10); | ||
if (isNaN(year) || year < 2023) { | ||
console.error(`Invalid year: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
// Second part should be a month | ||
const month = parseInt(parts[1], 10); | ||
if (isNaN(month) || month < 1 || month > 12) { | ||
console.error(`Invalid month: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
// Third part should be a day | ||
const day = parseInt(parts[2], 10); | ||
if (isNaN(day) || day < 1 || day > 31) { | ||
console.error(`Invalid day: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
// Fourth part should be HHmm | ||
const time = parts[3]; | ||
|
||
// Check length is 4 | ||
if (time.length !== 4) { | ||
console.error(`Invalid time: ${file}`); | ||
process.exit(1); | ||
} | ||
|
||
const hour = parseInt(time.substring(0, 2), 10); | ||
const minute = parseInt(time.substring(2), 10); | ||
if (isNaN(hour) || hour < 0 || hour > 23 || isNaN(minute) || minute < 0 || minute > 59) { | ||
console.error(`Invalid time: ${file}`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
console.log("All knex filenames are correct."); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
server/utils/knex/lib/dialects/mysql2/schema/mysql2-columncompiler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const ColumnCompilerMySQL = require("knex/lib/dialects/mysql/schema/mysql-columncompiler"); | ||
const { formatDefault } = require("knex/lib/formatter/formatterUtils"); | ||
const { log } = require("../../../../../../../src/util"); | ||
|
||
class KumaColumnCompiler extends ColumnCompilerMySQL { | ||
/** | ||
* Override defaultTo method to handle default value for TEXT fields | ||
* @param {any} value Value | ||
* @returns {string|void} Default value (Don't understand why it can return void or string, but it's the original code, lol) | ||
*/ | ||
defaultTo(value) { | ||
if (this.type === "text" && typeof value === "string") { | ||
log.debug("defaultTo", `${this.args[0]}: ${this.type} ${value} ${typeof value}`); | ||
// MySQL 8.0 is required and only if the value is written as an expression: https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html | ||
// MariaDB 10.2 is required: https://mariadb.com/kb/en/text/ | ||
return `default (${formatDefault(value, this.type, this.client)})`; | ||
} | ||
return super.defaultTo.apply(this, arguments); | ||
} | ||
} | ||
|
||
module.exports = KumaColumnCompiler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.