cockroachdb / cockroachdb/sequelize-cockroachdb

How to add foreign key in sequelize cockroachdb

Aperta
#10 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
55
Fork
18
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I have model like
```
let init = function() {
return user_management = connection.define('user_management', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
email_id: {
type: sequelize.STRING,
allowNull: false
},
password: {
type: sequelize.STRING
},
first_name: {
type: sequelize.STRING,
allowNull: false
},
middle_name: {
type: sequelize.STRING,
allowNull: true
},
last_name: {
type: sequelize.STRING,
allowNull: false
},
title: {
type: sequelize.STRING,
allowNull: false
},
company_name: {
type: sequelize.STRING,
allowNull: true
},
organisation_strength: {
type: sequelize.STRING,
allowNull: true
},
industry: {
type: sequelize.STRING,
allowNull: true
},
phone_number: {
type: sequelize.INTEGER,
allowNull: false
},
url: {
type: sequelize.STRING,
allowNull: true
},
personnel_number: {
type: sequelize.INTEGER,
allowNull: true
},
},
// I want to add unit id as foreign key in usermanagement table.
classMethods: {
associate: function(model) {
var usermanagement = model.user_management;
var unit = model.unit;
usermanagement.belongsTo(unit)
},
})
}
module.exports = init
```

I am getting error while trying to create table
Unhandled rejection SequelizeDatabaseError: unimplemented at or near "null"
**CREATE TABLE IF NOT EXISTS "user_managements" ("id" SERIAL , "email_id" VARCHAR(255) NOT NULL, "password" VARCHAR(255), "first_name" VARCHAR(255) NOT NULL, "middle_name" VARCHAR(255), "last_name" VARCHAR(255) NOT NULL, "title" VARCHAR(255) NOT NULL, "company_name" VARCHAR(255), "organisation_strength" VARCHAR(255), "industry" VARCHAR(255), "phone_number" INTEGER NOT NULL, "url" VARCHAR(255), "personnel_number" INTEGER, "user_role" VARCHAR(255) NOT NULL, "salt" VARCHAR(255), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "unitId" INTEGER REFERENCES "units" ("id") ON DELETE SET NULL ON UPDATE CASCADE, PRIMARY KEY ("id"));**

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.