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

Update postgres migration instruction and file location #1871

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ psql -h localhost -p 5435 -U postgres

When the realm server starts up it will automatically run DB migrations that live in the `packages/realm-server/migrations` folder. As part of development you may wish to run migrations manually as well as to create a new migration.

To create a new migration, from `packages/realm-server`, execute:
To create a new migration, from `packages/postgres`, execute:

```
pnpm migrate create name-of-migration
```

This creates a new migration file in `packages/realm-server/migrations`. You can then edit the newly created migration file with the details of your migration. We use `node-pg-migrate` to handle our migrations. You can find the API at https://salsita.github.io/node-pg-migrate.
This creates a new migration file in `packages/postgres/migrations`. You can then edit the newly created migration file with the details of your migration. We use `node-pg-migrate` to handle our migrations. You can find the API at https://salsita.github.io/node-pg-migrate.

To run the migration, execute:

Expand All @@ -154,7 +154,7 @@ To revert the migration, execute:
pnpm migrate down
```

Boxel also uses SQLite in order to run the DB in the browser as part of running browser tests (and eventually we may run the realm server in the browser to provide a local index). We treat the Postgres database schema as the source of truth and derive the SQLite schema from it. Therefore, once you author and apply a migration, you should generate a new schema SQL file for SQLite. To generate a new SQLite schema, from `packages/realm-server`, execute:
Boxel also uses SQLite in order to run the DB in the browser as part of running browser tests (and eventually we may run the realm server in the browser to provide a local index). We treat the Postgres database schema as the source of truth and derive the SQLite schema from it. Therefore, once you author and apply a migration, you should generate a new schema SQL file for SQLite. To generate a new SQLite schema, from `packages/postgres`, execute:

```
pnpm make-schema
Expand Down
2 changes: 1 addition & 1 deletion packages/host/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function getLatestSchemaFile() {
['development', 'test'].includes(process.env.EMBER_ENV)
) {
throw new Error(
`The sqlite schema file is out of date--please regenerate the sqlite schema file using \`pnpm make-schema\` in the realm server`,
`The sqlite schema file is out of date--please regenerate the sqlite schema file using \`pnpm make-schema\` in the postgres package`,
);
}
return path.join(schemaDir, latestSchemaFile);
Expand Down
3 changes: 2 additions & 1 deletion packages/postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"@types/pg": "^8.11.5",
"fs-extra": "^10.1.0",
"node-pg-migrate": "^6.2.2",
"pg": "^8.11.5"
"pg": "^8.11.5",
"ts-node": "^10.9.1"
},
"devDependencies": {
"concurrently": "^8.0.1",
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading