Fix small typo in documentation
Also make sure the migrations run in order. Sets are unordered and thus can't guarantee the expected sorted order required in migrations.
This commit is contained in:
@@ -20,7 +20,7 @@ Download/copy [`docker-compose.yml`](/docker-compose.yml) and [`.env.sample`](/.
|
||||
|
||||
```sh
|
||||
$ mkdir data-files # local directory for storing user-uploaded files
|
||||
$ chown -R 1993:1993 data-files # solves permission related issues
|
||||
$ sudo chown -R 1993:1993 data-files # solves permission related issues in the container with uploading files
|
||||
$ docker compose up -d # makes the app available at http://localhost:8000
|
||||
$ docker compose run --rm website bash -c "cd /app && make migrate-db" # initializes/updates the database (only needs to be executed the first time and on any updates)
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@ interface Migration {
|
||||
executed_at: Date;
|
||||
}
|
||||
|
||||
async function getExecutedMigrations() {
|
||||
async function getExecutedMigrations(): Promise<Set<string>> {
|
||||
const executedMigrations = new Set(
|
||||
Array.from(
|
||||
(await db.query<Migration>(sql`SELECT * FROM "bewcloud_migrations" ORDER BY "name" ASC`)).map((migration) =>
|
||||
@@ -26,7 +26,7 @@ async function getExecutedMigrations() {
|
||||
return executedMigrations;
|
||||
}
|
||||
|
||||
async function getMissingMigrations() {
|
||||
async function getMissingMigrations(): Promise<string[]> {
|
||||
const existingMigrations: Set<string> = new Set();
|
||||
|
||||
for await (const migrationFile of migrationsDirectory) {
|
||||
@@ -60,10 +60,10 @@ async function getMissingMigrations() {
|
||||
// The table likely doesn't exist, so run everything.
|
||||
}
|
||||
|
||||
return migrationsToExecute;
|
||||
return Array.from(migrationsToExecute).sort();
|
||||
}
|
||||
|
||||
async function runMigrations(missingMigrations: Set<string>) {
|
||||
async function runMigrations(missingMigrations: string[]): Promise<void> {
|
||||
for (const missingMigration of missingMigrations) {
|
||||
console.log(`Running "${missingMigration}"...`);
|
||||
|
||||
@@ -90,7 +90,7 @@ try {
|
||||
|
||||
await runMigrations(missingMigrations);
|
||||
|
||||
if (missingMigrations.size === 0) {
|
||||
if (missingMigrations.length === 0) {
|
||||
console.log('No migrations to run!');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user