const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
    const ApiKey = sequelize.define('apikey', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        api_key: { type: DataTypes.STRING(150), allowNull: true },
        api_secret: { type: DataTypes.STRING(150), allowNull: true },
        api_url: { type: DataTypes.STRING(200), allowNull: true },

        // fk
        user_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            references: {
                model: 'users',
                key: 'id'
            }
        },
    }, {
        tableName: 'apikeys',
    }, {
        freezeTableName: true
    });

    return ApiKey;
};
