Models and migration for sequelize

This commit is contained in:
Supositware 2022-08-14 22:27:46 +02:00
parent 50aecd546a
commit c52b19a678
43 changed files with 932 additions and 0 deletions

View file

@ -0,0 +1,38 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Tags', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
trigger: {
type: Sequelize.TEXT,
},
response: {
type: Sequelize.TEXT,
},
ownerID: {
type: Sequelize.BIGINT,
},
serverID: {
type: Sequelize.BIGINT,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Tags');
}
};

View file

@ -0,0 +1,35 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('autoresponses', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
trigger: {
type: Sequelize.TEXT
},
response: {
type: Sequelize.TEXT
},
type: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('autoresponses');
}
};

View file

@ -0,0 +1,32 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('autoresponseStats', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
serverID: {
type: Sequelize.BIGINT
},
stat: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('autoresponseStats');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('guessLeaderboards', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
memberID: {
type: Sequelize.BIGINT
},
try: {
type: Sequelize.INTEGER
},
difficulty: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('guessLeaderboards');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('bannedWords', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
word: {
type: Sequelize.STRING
},
serverID: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('bannedWords');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('TwitterBlacklists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userID: {
type: Sequelize.BIGINT
},
reason: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('TwitterBlacklists');
}
};

View file

@ -0,0 +1,27 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('guildBlacklists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
guildID: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('guildBlacklists');
}
};

View file

@ -0,0 +1,27 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('userBlacklists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userID: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('userBlacklists');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('borgars', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userID: {
type: Sequelize.BIGINT
},
level: {
type: Sequelize.INTEGER
},
xp: {
type: Sequelize.INTEGER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('borgars');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('donators', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userID: {
type: Sequelize.BIGINT
},
comment: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('donators');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('joinChannels', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
channelID: {
type: Sequelize.BIGINT
},
guildID: {
type: Sequelize.BIGINT
},
message: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('joinChannels');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('leaveChannels', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
channelID: {
type: Sequelize.BIGINT
},
guildID: {
type: Sequelize.BIGINT
},
message: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('leaveChannels');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('whitelistWords', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
word: {
type: Sequelize.STRING
},
serverID: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('whitelistWords');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('quotationStats', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
serverID: {
type: Sequelize.BIGINT
},
stat: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('quotationStats');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('commandBlocks', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
serverID: {
type: Sequelize.BIGINT
},
command: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('commandBlocks');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('LogStats', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
guild: {
type: Sequelize.BIGINT
},
channel: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('LogStats');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('ytpHashes', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
hash: {
type: Sequelize.STRING
},
link: {
type: Sequelize.STRING
},
messageID: {
type: Sequelize.BIGINT
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('ytpHashes');
}
};

View file

@ -0,0 +1,30 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('ytpblacklists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userID: {
type: Sequelize.BIGINT
},
reason: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('ytpblacklists');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Blacklists', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
type: {
type: Sequelize.STRING
},
uid: {
type: Sequelize.STRING
},
reason: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Blacklists');
}
};

View file

@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('commandblockusers', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
serverID: {
type: Sequelize.BIGINT
},
userID: {
type: Sequelize.BIGINT
},
command: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('commandblockusers');
}
};

3
migrations/package.json Normal file
View file

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

14
models/autoresponse.js Normal file
View file

@ -0,0 +1,14 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = (sequelize, DataTypes) => {
const autoresponse = sequelize.define('autoresponse', {
trigger: DataTypes.STRING,
response: DataTypes.STRING,
type: DataTypes.STRING
}, {});
autoresponse.associate = function(models) {
// associations can be defined here
};
return autoresponse;
};

View file

@ -0,0 +1,13 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = (sequelize, DataTypes) => {
const autoresponseStat = sequelize.define('autoresponseStat', {
serverID: DataTypes.STRING,
stat: DataTypes.STRING
}, {});
autoresponseStat.associate = function(models) {
// associations can be defined here
};
return autoresponseStat;
};

11
models/bannedwords.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const bannedWords = sequelize.define('bannedWords', {
word: DataTypes.STRING,
serverID: DataTypes.BIGINT
}, {});
bannedWords.associate = function(models) {
// associations can be defined here
};
return bannedWords;
};

25
models/blacklists.js Normal file
View file

@ -0,0 +1,25 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Blacklists extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
Blacklists.init({
type: DataTypes.STRING,
uid: DataTypes.STRING,
reason: DataTypes.STRING
}, {
sequelize,
modelName: 'Blacklists',
});
return Blacklists;
};

12
models/borgar.js Normal file
View file

@ -0,0 +1,12 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const borgar = sequelize.define('borgar', {
userID: DataTypes.BIGINT,
level: DataTypes.INTEGER,
xp: DataTypes.INTEGER
}, {});
borgar.associate = function(models) {
// associations can be defined here
};
return borgar;
};

11
models/commandblock.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const commandBlock = sequelize.define('commandBlock', {
serverID: DataTypes.BIGINT,
command: DataTypes.STRING
}, {});
commandBlock.associate = function(models) {
// associations can be defined here
};
return commandBlock;
};

View file

@ -0,0 +1,25 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class commandblockuser extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
commandblockuser.init({
serverID: DataTypes.BIGINT,
userID: DataTypes.BIGINT,
command: DataTypes.STRING
}, {
sequelize,
modelName: 'commandblockuser',
});
return commandblockuser;
};

11
models/donator.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const donator = sequelize.define('donator', {
userID: DataTypes.BIGINT,
comment: DataTypes.STRING
}, {});
donator.associate = function(models) {
// associations can be defined here
};
return donator;
};

View file

@ -0,0 +1,12 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const guessLeaderboard = sequelize.define('guessLeaderboard', {
memberID: DataTypes.INTEGER,
try: DataTypes.INTEGER,
difficulty: DataTypes.STRING
}, {});
guessLeaderboard.associate = function(models) {
// associations can be defined here
};
return guessLeaderboard;
};

10
models/guildblacklist.js Normal file
View file

@ -0,0 +1,10 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const guildBlacklist = sequelize.define('guildBlacklist', {
guildID: DataTypes.BIGINT
}, {});
guildBlacklist.associate = function(models) {
// associations can be defined here
};
return guildBlacklist;
};

37
models/index.js Normal file
View file

@ -0,0 +1,37 @@
'use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;

12
models/joinchannel.js Normal file
View file

@ -0,0 +1,12 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const joinChannel = sequelize.define('joinChannel', {
channelID: DataTypes.BIGINT,
guildID: DataTypes.BIGINT,
message: DataTypes.STRING
}, {});
joinChannel.associate = function(models) {
// associations can be defined here
};
return joinChannel;
};

12
models/leavechannel.js Normal file
View file

@ -0,0 +1,12 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const leaveChannel = sequelize.define('leaveChannel', {
channelID: DataTypes.BIGINT,
guildID: DataTypes.BIGINT,
message: DataTypes.STRING
}, {});
leaveChannel.associate = function(models) {
// associations can be defined here
};
return leaveChannel;
};

11
models/logstats.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const LogStats = sequelize.define('LogStats', {
guild: DataTypes.BIGINT,
channel: DataTypes.BIGINT
}, {});
LogStats.associate = function(models) {
// associations can be defined here
};
return LogStats;
};

3
models/package.json Normal file
View file

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

11
models/quotationstat.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const quotationStat = sequelize.define('quotationStat', {
serverID: DataTypes.BIGINT,
stat: DataTypes.STRING
}, {});
quotationStat.associate = function(models) {
// associations can be defined here
};
return quotationStat;
};

15
models/tag.js Normal file
View file

@ -0,0 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable indent */
'use strict';
module.exports = (sequelize, DataTypes) => {
const Tag = sequelize.define('Tag', {
trigger: DataTypes.STRING,
response: DataTypes.STRING,
ownerID: DataTypes.BIGINT,
serverID: DataTypes.BIGINT
}, {});
Tag.associate = function(models) {
// associations can be defined here
};
return Tag;
};

View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const TwitterBlacklist = sequelize.define('TwitterBlacklist', {
userID: DataTypes.BIGINT,
reason: DataTypes.STRING
}, {});
TwitterBlacklist.associate = function(models) {
// associations can be defined here
};
return TwitterBlacklist;
};

10
models/userblacklist.js Normal file
View file

@ -0,0 +1,10 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const userBlacklist = sequelize.define('userBlacklist', {
userID: DataTypes.BIGINT
}, {});
userBlacklist.associate = function(models) {
// associations can be defined here
};
return userBlacklist;
};

11
models/whitelistword.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const whitelistWord = sequelize.define('whitelistWord', {
word: DataTypes.STRING,
serverID: DataTypes.BIGINT
}, {});
whitelistWord.associate = function(models) {
// associations can be defined here
};
return whitelistWord;
};

11
models/ytpblacklist.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const ytpblacklist = sequelize.define('ytpblacklist', {
userID: DataTypes.BIGINT,
reason: DataTypes.STRING
}, {});
ytpblacklist.associate = function(models) {
// associations can be defined here
};
return ytpblacklist;
};

11
models/ytphash.js Normal file
View file

@ -0,0 +1,11 @@
'use strict';
module.exports = (sequelize, DataTypes) => {
const ytpHash = sequelize.define('ytpHash', {
hash: DataTypes.STRING,
messageID: DataTypes.BIGINT
}, {});
ytpHash.associate = function(models) {
// associations can be defined here
};
return ytpHash;
};