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

module.exports = (sequelize) => {
    const App = sequelize.define('app', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        creation: { type: DataTypes.DATE, allowNull: false },
        modified: { type: DataTypes.DATE, allowNull: false },
        modified_by: { type: DataTypes.INTEGER, allowNull: false },
        owner: { type: DataTypes.INTEGER, allowNull: false },
        enabled: { type: DataTypes.BOOLEAN, allowNull: false },
        
        name: { type: DataTypes.STRING(100), allowNull: false, unique: true },
        display_name: { type: DataTypes.STRING(150), allowNull: true, unique: true },
        slug_name: { type: DataTypes.STRING(100), allowNull: true, unique: true },
        app_logo: { type: DataTypes.STRING, allowNull: true },
        app_logo_secondary: { type: DataTypes.STRING, allowNull: true },
        app_logo_navbar: { type: DataTypes.STRING, allowNull: true },
        app_url: { type: DataTypes.STRING(100), allowNull: true },
        opener_description: { type: DataTypes.TEXT, allowNull: true },
        about_description: { type: DataTypes.TEXT, allowNull: true },
        feature_description: { type: DataTypes.TEXT, allowNull: true },
    }, {
        tableName: 'apps',
        freezeTableName: true
    });

    /**
     * Associates the App model with other models.
     * @param {object} models - The models to associate with.
     */
    App.associate = (models) => {
        
    };

    return App;
};

