我想强制一个表的自动增量字段为某个值,我试着用这个:
ALTER TABLE product AUTO_INCREMENT = 1453
Run Code Online (Sandbox Code Playgroud)
和
ALTER SEQUENCE product RESTART WITH 1453;
ERROR: relation "your_sequence_name" does not exist
Run Code Online (Sandbox Code Playgroud)
我是postgres的新手:(
我有一个表product与Id和name领域
我正在尝试为每个测试自动化构建,播种和销毁我的数据库。我正在使用PostgreSQL,Mocha和Sequelize。
我找到了一个库:sequelize-fixtures,使我步入正轨,但最终它非常不一致,有时会引发约束错误:Unhandled rejection SequelizeUniqueConstraintError: Validation error即使我对模型没有任何验证。
这是我进行测试的方式
const sequelize = new Sequelize('test_db', 'db', null, {
logging: false,
host: 'localhost',
port: '5432',
dialect: 'postgres',
protocol: 'postgres'
})
describe('/auth/whoami', () => {
beforeEach((done) => {
Fixtures.loadFile('test/fixtures/data.json', models)
.then(function(){
done()
})
})
afterEach((done) => {
sequelize.sync({
force: true
}).then(() => {
done()
})
})
it('should connect to the DB', (done) => {
sequelize.authenticate()
.then((err) => {
expect(err).toBe(undefined)
done()
})
})
it('should test getting a user', (done) => …Run Code Online (Sandbox Code Playgroud)