justindra
02/21/2022, 1:29 AMsst:deploy
and it seems to run fine without issues, and then I ran sst:start
and also seems fine. But when I go to apply the one migration I have, it's coming with this error and after looking at it, doesn't seem like it was run at all.
ERROR TypeError: Unknown file extension ".ts" for /home/test-postgres/stacks/db-migrations/2022-02-20.ts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/test-postgres/stacks/db-migrations/2022-02-20.ts
at new NodeError (internal/errors.js:322:7)
at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:71:15)
at Loader.getFormat (internal/modules/esm/loader.js:105:42)
at Loader.getModuleJob (internal/modules/esm/loader.js:243:31)
at async Loader.import (internal/modules/esm/loader.js:177:17)
at async DynamicFileMigrationProvider.getMigrations (/home/test-postgres/.sst/artifacts/dev-klic-weather-station-StatickStack-RDSCluster-MigrationFunction/home/test-postgres/node_modules/@serverless-stack/resources/dist/RDS_migrator/index.js:13236:27)
at async Migrator.resolveMigrations_fn (/home/test-postgres/.sst/artifacts/dev-klic-weather-station-StatickStack-RDSCluster-MigrationFunction/home/test-postgres/node_modules/@serverless-stack/resources/dist/RDS_migrator/index.js:12040:25)
at async Migrator.getMigrations (/home/test-postgres/.sst/artifacts/dev-klic-weather-station-StatickStack-RDSCluster-MigrationFunction/home/test-postgres/node_modules/@serverless-stack/resources/dist/RDS_migrator/index.js:11899:24)
at async Runtime.handler (/home/test-postgres/.sst/artifacts/dev-klic-weather-station-StatickStack-RDSCluster-MigrationFunction/home/test-postgres/node_modules/@serverless-stack/resources/dist/RDS_migrator/index.js:13220:12)
The migration file is just called 2022-02-20.ts
and contains the following:
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`CREATE EXTENSION postgis`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`DROP EXTENSION extensionName;`.execute(db);
}
So looks like it's not transpiling that TS file before running the migration? Is this expected or is there something that I should be enabling?thdxr
02/21/2022, 2:15 AMthdxr
02/21/2022, 2:16 AMjustindra
02/21/2022, 3:21 AMkysely
directly. It looks like as kysely
is actually transpiled for the MigrationFunction
so it is no longer valid. Any possibilities of keeping that library out in node_modules
so its not bundled together?thdxr
02/21/2022, 3:33 AMjustindra
02/21/2022, 3:34 AMconst sql = require('kysely').sql;
async function up(db) {
await sql`CREATE EXTENSION postgis`.execute(db);
}
async function down(db) {
await sql`DROP EXTENSION extensionName;`.execute(db);
}
module.exports = { up, down };
As you can see require('kysely');
fails as there is no kysely module.Frank
CREATE EXTENSION
with something like this
async function up(db) {
await db.schema
.createExtension("postgis")
.execute()
}
justindra
02/21/2022, 3:44 AMkisely
doesn't have any methods that I could find on their docs around extensionsthdxr
02/21/2022, 4:17 AMdb.raw("CREATE EXTENSION postgis").execute()
justindra
02/21/2022, 4:28 AMthdxr
02/21/2022, 4:37 AMjustindra
02/21/2022, 5:36 AM