foreign key camel case issue in postgres on heroku server

153 views Asked by At

i am creating table on heroku successfully but the problems is foreign key when add foreign key it will automatically created in small letter by default postgres accept foreign key like serviceId format

this is my table

CREATE TABLE service_categories (
    id serial PRIMARY KEY,
    "serviceId"                 integer   NOT NULL,
    service_category_name       VARCHAR ( 50 )  NOT NULL,
    "createdAt"                 TIMESTAMP DEFAULT NOW(),
    "updatedAt"                 TIMESTAMP DEFAULT NOW()
);

but on heroku its created serviceid rather then serviceId any body can help how can i create foreign key like serviceId

1

There are 1 answers

0
Shahid On

just double quotes in the model like

const Order = db.define("my_orders", {
    id: {
        type: Sequelize.INTEGER,
        autoIncrement: true,
        allowNull: false,
        primaryKey: true,
    },
    "serviceSubCategoryId": {
        type: Sequelize.INTEGER
    },
   "userId": {
        type: Sequelize.INTEGER
    }
   
});