Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egg官方配置 初始化 Migrations 并不会按照文档创建目录 #3367

Closed
CGerAJ opened this issue Jan 7, 2019 · 3 comments · Fixed by #3372
Closed

egg官方配置 初始化 Migrations 并不会按照文档创建目录 #3367

CGerAJ opened this issue Jan 7, 2019 · 3 comments · Fixed by #3372
Assignees

Comments

@CGerAJ
Copy link

CGerAJ commented Jan 7, 2019

What happens?

egg官方配置 初始化 Migrations 并不会按照文档创建目录
https://eggjs.org/zh-cn/tutorials/sequelize.html

最小可复现仓库

请使用 egg-init --type=simple bug 创建,并上传到你的 GitHub 仓库

https://github.com/YOUR_REPOSITORY_URL

复现步骤,错误日志以及相关配置

按照官网配置 多次卸载安装 同样的问题

➜  sequelize-project npx sequelize init:config

Sequelize CLI [Node: 9.2.0, CLI: 5.4.0, ORM: 4.42.0]

Created "database/config.json"
➜  sequelize-project npx sequelize init:migrations

Sequelize CLI [Node: 9.2.0, CLI: 5.4.0, ORM: 4.42.0]

Successfully created migrations folder at "/Users/xiangyujie/code/sequelize-project/database/migrations".

image

相关环境信息

  • 操作系统:macOS 10.14.2
  • Node 版本:v9.2.0
  • Egg 版本:最新版
@dead-horse
Copy link
Member

恩,此处的文档有问题,应该是可以直接 npx sequelize init ,感谢反馈。你可以先手动创建这几个目录。

@CGerAJ
Copy link
Author

CGerAJ commented Jan 8, 2019

我今天再试试 在我提issue之前 我手动创建了目录 但是不能读取到这个model

this.model.User

所以只能提issue 目前可以跑通 感谢🙏

生成的数据库配置目录 database/config.json 建议文档新增如果用户提示高版本禁用警告
建议新增 operatorsAliases:false 字段来跑通测试

@ghost ghost deleted a comment from CGerAJ Jan 11, 2019
@tozzz
Copy link

tozzz commented Jan 15, 2020

今天按文档走的时候,执行那两个初始化指令。也没有按描述生成database/config.json和database/migrations。对比了sequelize官网migrations的文档后发现,猜测可能是path.join()和path.resolve()引起的坑。egg文档里的.sequelizerc里的用的path.join(),该方法碰到‘/’会认为是普通的目录层级连接符,resolve则会认为是根路径。前者返回多是相对路径,后者是绝对路径。
`'use strict';

const path = require('path');

module.exports = {
config: path.join(__dirname, 'database/config.json'),
'migrations-path': path.join(__dirname, 'database/migrations'),
'seeders-path': path.join(__dirname, 'database/seeders'),
'models-path': path.join(__dirname, 'app/model'),
};`
把上面的join改成resolve后,可按文档描述生成特定位置的文件和目录。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants