gpt4 book ai didi

amazon-web-services - Sequelize Serverless 离线迁移出错

转载 作者:行者123 更新时间:2023-12-03 22:34:12 28 4
gpt4 key购买 nike

使用此命令 sls offline start --httpPort 12012 -s local 服务器在本地环境上成功启动。
但是这个命令结果是错误 sls offline migrations --httpPort 12012 -s local

  Serverless Error ---------------------------------------

"migrations" is not a valid sub command. Run "serverless offline" to see a more helpful error message for this command.

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com

Your Environment Information ---------------------------
Operating System: linux
Node Version: 14.4.0
Framework Version: 1.75.1
Plugin Version: 3.6.16
SDK Version: 2.3.1
Components Version: 2.32.0
如果我运行 serverless migrations up 会发生错误。
Serverless: Setting up connections...
Serverless: Looking for pending migrations...
Executing (default): CREATE TABLE IF NOT EXISTS `SequelizeMeta` (`name` VARCHAR(255) NOT NULL UNIQUE , PRIMARY KEY (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;
Executing (default): SHOW INDEX FROM `SequelizeMeta`
Executing (default): SELECT `name` FROM `SequelizeMeta` AS `SequelizeMeta` ORDER BY `SequelizeMeta`.`name` ASC;
Serverless: Applying pending migrations...
Executing (default): CREATE TABLE IF NOT EXISTS `SequelizeMeta` (`name` VARCHAR(255) NOT NULL UNIQUE , PRIMARY KEY (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;
Executing (default): SHOW INDEX FROM `SequelizeMeta`
Executing (default): SELECT `name` FROM `SequelizeMeta` AS `SequelizeMeta` ORDER BY `SequelizeMeta`.`name` ASC;
Executing (default): CREATE TABLE IF NOT EXISTS `SequelizeMeta` (`name` VARCHAR(255) NOT NULL UNIQUE , PRIMARY KEY (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;
Executing (default): SHOW INDEX FROM `SequelizeMeta`
Executing (default): SELECT `name` FROM `SequelizeMeta` AS `SequelizeMeta` ORDER BY `SequelizeMeta`.`name` ASC;
Serverless: Error while applying migrations
Serverless: Looking for migration that has problems...
Executing (default): CREATE TABLE IF NOT EXISTS `SequelizeMeta` (`name` VARCHAR(255) NOT NULL UNIQUE , PRIMARY KEY (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;
Executing (default): SHOW INDEX FROM `SequelizeMeta`
Executing (default): SELECT `name` FROM `SequelizeMeta` AS `SequelizeMeta` ORDER BY `SequelizeMeta`.`name` ASC;
Serverless: Something wrong with 20200728165728-init.js
目前,数据库是通过使用 sequelize 同步更新的,有时会锁定表。
import Sequelize from 'sequelize';
import mysql2 from 'mysql2';

const db = new Sequelize(
process.env.DB_NAME,
process.env.DB_USERNAME,
process.env.DB_PASSWORD,
{
omitNull: true,
dialect: process.env.DB_DIALECT,
dialectModule: mysql2,
dialectOptions: {
supportBigNumbers: true
},
host: process.env.DB_HOST,
});

let synced = false;
const getSequelize = () => {
if (!synced) {
db.sync({ alter: true })
.then(() => {
console.log(`Database & tables synchronised!`)
});

synced = true;
}

return db;
}

export default getSequelize();
这些是包含在配置文件中的插件
plugins:
- serverless-webpack
- serverless-offline
- serverless-pseudo-parameters
- serverless-prune-plugin
- serverless-sequelize-migrations

最佳答案

看起来你拼错了 migrations
错误消息说:

"migratins" is not a valid sub command. Run "serverless offline" to see a more helpful error message for this command.

关于amazon-web-services - Sequelize Serverless 离线迁移出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63141209/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com