|
@@ -1,19 +1,29 @@
|
|
|
async function up(knex) {
|
|
async function up(knex) {
|
|
|
- await knex.schema.alterTable("users", table => {
|
|
|
|
|
- table.dropColumn("cooldowns");
|
|
|
|
|
- table.datetime("cooldown").nullable();
|
|
|
|
|
- table.integer("malicious_attempts").defaultTo(0);
|
|
|
|
|
- });
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-async function down(knex) {
|
|
|
|
|
- await knex.schema.alterTable("users", table => {
|
|
|
|
|
- table.dropColumn("cooldown");
|
|
|
|
|
- table.json("cooldowns").defaultTo("[]");
|
|
|
|
|
- table.dropColumn("malicious_attempts");
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const hasCooldowns = await knex.schema.hasColumn("users", "cooldowns");
|
|
|
|
|
+ if (hasCooldowns) {
|
|
|
|
|
+ await knex.schema.alterTable("users", table => {
|
|
|
|
|
+ table.dropColumn("cooldowns");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const hasCooldown = await knex.schema.hasColumn("users", "cooldown");
|
|
|
|
|
+ if (!hasCooldown) {
|
|
|
|
|
+ await knex.schema.alterTable("users", table => {
|
|
|
|
|
+ table.datetime("cooldown").nullable();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const hasMaliciousAttempts = await knex.schema.hasColumn("users", "malicious_attempts");
|
|
|
|
|
+ if (!hasMaliciousAttempts) {
|
|
|
|
|
+ await knex.schema.alterTable("users", table => {
|
|
|
|
|
+ table.integer("malicious_attempts").notNullable().defaultTo(0);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function down(knex) {}
|
|
|
|
|
+
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
up,
|
|
up,
|
|
|
down
|
|
down
|