0
0
This commit is contained in:
syuilo 2019-05-14 23:54:39 +09:00
parent 678d610cd6
commit e5409db0e8
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
4 changed files with 23 additions and 22 deletions

View File

@ -8,32 +8,13 @@ If you encounter any problems with updating, please try the following:
Migration Migration
------------------------------ ------------------------------
#### 1 #### 1
`ormconfig.json`という名前で、Misskeyのインストール場所(package.jsonとかがあるディレクトリ)に新たなファイルを作る。中身は次のようにします:
``` json
{
"type": "postgres",
"host": "PostgreSQLのホスト",
"port": 5432,
"username": "PostgreSQLのユーザー名",
"password": "PostgreSQLのパスワード",
"database": "PostgreSQLのデータベース名",
"entities": ["src/models/entities/*.ts"],
"migrations": ["migration/*.ts"],
"cli": {
"migrationsDir": "migration"
}
}
```
上記の各種PostgreSQLの設定(ポートも)は、設定ファイルに書いてあるものをコピーしてください。
#### 2
``` ```
npm i -g ts-node npm i -g ts-node
``` ```
#### 3 #### 2
``` ```
ts-node ./node_modules/typeorm/cli.js migration:run npm run migrate
``` ```
How to migrate to v11 from v10 How to migrate to v11 from v10

View File

@ -199,7 +199,7 @@ const user = await Users.findOne(userId).then(ensure);
``` ```
### Migration作成方法 ### Migration作成方法
コードの変更をした後、`ormconfig.json`書き方はCONTRIBUTING.mdを参照)を用意し、 コードの変更をした後、`ormconfig.json``npm run ormconfig`で生成)を用意し、
``` ```
npm i -g ts-node npm i -g ts-node

View File

@ -12,6 +12,8 @@
"scripts": { "scripts": {
"start": "node ./index.js", "start": "node ./index.js",
"init": "node ./built/init.js", "init": "node ./built/init.js",
"ormconfig": "node ./built/ormconfig.js",
"migrate": "npm run ormconfig && ts-node ./node_modules/typeorm/cli.js migration:run",
"build": "webpack && gulp build", "build": "webpack && gulp build",
"webpack": "webpack", "webpack": "webpack",
"watch": "webpack --watch", "watch": "webpack --watch",

18
src/ormconfig.ts Normal file
View File

@ -0,0 +1,18 @@
import * as fs from 'fs';
import config from './config';
const json = {
type: 'postgres',
host: config.db.host,
port: config.db.port,
username: config.db.user,
password: config.db.pass,
database: config.db.db,
entities: ['src/models/entities/*.ts'],
migrations: ['migration/*.ts'],
cli: {
migrationsDir: 'migration'
}
};
fs.writeFileSync('ormconfig.json', JSON.stringify(json));