20240911230301_change_cooldown.js 757 B

12345678910111213141516171819202122232425262728293031
  1. async function up(knex) {
  2. const hasCooldowns = await knex.schema.hasColumn("users", "cooldowns");
  3. if (hasCooldowns) {
  4. await knex.schema.alterTable("users", table => {
  5. table.dropColumn("cooldowns");
  6. });
  7. }
  8. const hasCooldown = await knex.schema.hasColumn("users", "cooldown");
  9. if (!hasCooldown) {
  10. await knex.schema.alterTable("users", table => {
  11. table.datetime("cooldown").nullable();
  12. });
  13. }
  14. const hasMaliciousAttempts = await knex.schema.hasColumn("users", "malicious_attempts");
  15. if (!hasMaliciousAttempts) {
  16. await knex.schema.alterTable("users", table => {
  17. table.integer("malicious_attempts").notNullable().defaultTo(0);
  18. });
  19. }
  20. }
  21. async function down(knex) {}
  22. module.exports = {
  23. up,
  24. down
  25. };