Problem For `Rename Column` With `Keep Rows` in Sequelize
kasrakhamesi opened this issue · 0 comments
Hi,I have table with 5 column and 1000 row, I want rename second column from imageUrl to slug for example.
and I want sequelize do not delete row in old column and don't want create new column
only I want rename column with all rows.
but in this code
import { Post } from '/post/entities/post.entity';
import { Module } from '@nestjs/common';
import { SequelizeModule } from '@nestjs/sequelize';
@module({
imports: [
SequelizeModule.forRoot({
dialect: 'mysql',
host: host,
port: port,
username: user,
password: pass,
database: db,
models: [Post ],
logging: true,
autoLoadModels: true,
synchronize: true,
sync: { alter: true },
}),
],
exports: [SequelizeModule],
})
export class DatabaseModule {}
Sequelize create new column with name slug and remove imageUrl and the row in imageUrl not transfered to slug column and slug column have empty or null row.
if I change : sync: { alter: true } to sync: { alter: { drop : false }}, Sequelize create new column with name slug and imageUrl exist too.
if I change : sync: { alter: true } to sync: { force :true }, Sequelize delete all rows
so How can fix that ?
Versions
"@nestjs/sequelize": "^9.0.2",
"sequelize": "^6.32.1",
"sequelize-typescript": "^2.1.5",
"@types/sequelize": "^4.28.15",
"typescript": "^4.7.4"
Framework
I Using nest.js