in src/resources/sql.ts [68:88]
async function runSetupQueries(info: ResourceInfo) {
const connectionString = await getSqlConnectionString(info);
const poolConnection = await createPoolConnnection(connectionString);
try {
await poolConnection
.request()
.query(`ALTER DATABASE ${dbName} SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);`);
for (const table of [sqlTriggerTable, sqlNonTriggerTable]) {
await poolConnection
.request()
.query(
`CREATE TABLE dbo.${table} ([id] UNIQUEIDENTIFIER PRIMARY KEY, [testData] NVARCHAR(200) NOT NULL);`
);
await poolConnection.request().query(`ALTER TABLE dbo.${table} ENABLE CHANGE_TRACKING;`);
}
} finally {
await poolConnection.close();
}
}