K
Kysely16mo ago
zell2890

Running a function during migration

I am looking to use Kysely with TimescaleDB, which is an extension of Postgres to support timeseries data. There are a few places where I know I won't have type support, and executing raw sql is fine for my purposes. However, the process to create a timeseries table invokes a specific function via SELECT e.g. : SELECT create_hypertable('conditions', 'time', 'location', 4); Since this is part of the table creation, I would like to make sure it happens during migration step. Is there a way to run raw sql as part of a migration?
1 Reply
koskimas
koskimas16mo ago
You can always run any SQL you want using the sql template tag.
await sql`select create_hypertable('conditions', 'time', 'location', 4)`.execute(db)
await sql`select create_hypertable('conditions', 'time', 'location', 4)`.execute(db)
Want results from more Discord servers?
Add your server