sequelize table without column 'id'
If you don't define a primaryKey
then sequelize uses id
by default.
If you want to set your own, just use primaryKey: true
on your column.
AcademyModule = sequelize.define('academy_module', { academy_id: { type: DataTypes.INTEGER, primaryKey: true }, module_id: DataTypes.INTEGER, module_module_type_id: DataTypes.INTEGER, sort_number: DataTypes.INTEGER, requirements_id: DataTypes.INTEGER}, { freezeTableName: true});
If you want to completely disable the primary key for the table, you can use Model.removeAttribute
. Be warned that this could cause problems in the future, as Sequelize is an ORM and joins will need extra setup.
const AcademyModule = sequelize.define('academy_module', { academy_id: DataTypes.INTEGER, module_id: DataTypes.INTEGER, module_module_type_id: DataTypes.INTEGER, sort_number: DataTypes.INTEGER, requirements_id: DataTypes.INTEGER}, { freezeTableName: true});AcademyModule.removeAttribute('id');
For a composite primary key, you should add "primaryKey: true" to all columns part of the primary key. Sequelize considers such columns to be part of a composite primary key.