MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / ensureSchema

Function ensureSchema

cloud-sql/sqlserver/mssql/index.js:98–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96};
97
98const ensureSchema = async pool => {
99 // Wait for tables to be created (if they don't already exist).
100 await pool.request().query(
101 `IF NOT EXISTS (
102 SELECT * FROM sysobjects WHERE name='votes' and xtype='U')
103 CREATE TABLE votes (
104 vote_id INT NOT NULL IDENTITY,
105 time_cast DATETIME NOT NULL,
106 candidate VARCHAR(6) NOT NULL,
107 PRIMARY KEY (vote_id));`
108 );
109 console.log("Ensured that table 'votes' exists");
110};
111
112let pool;
113const poolPromise = createPool()

Callers 1

index.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected