// export-full-schema.ts
import { DataSource } from "typeorm";
import { entities } from "./entities";
async function exportFullSchema() {
const tempDataSource = new DataSource({
type: "postgres",
host: "localhost",
database: "temp_db", // Use a temporary empty database
synchronize: false,
logging: false,
entities: entities,
});
await tempDataSource.initialize();
// This will generate full schema against empty db
const sqlInMemory = await tempDataSource.driver
.createSchemaBuilder()
.log();
sqlInMemory.upQueries.forEach(query => {
console.log(query.query + ";");
});
await tempDataSource.destroy();
}
// Run the export
exportFullSchema();