const createTable = async config => { // Connect to the database config.host = `/cloudsql/${config.connectionName}`; const knex = Knex({client: 'pg', connection: config}); // Create the "votes" table try { await knex.schema.createTable('votes', table => { table.bigIncrements('vote_id').notNull(); table.timestamp('time_cast').notNull(); table.specificType('candidate', 'CHAR(6) NOT NULL'); }); console.log(`Successfully created 'votes' table.`); return knex.destroy(); } catch (err) { console.error(`Failed to create 'votes' table:`, err); if (knex) { knex.destroy(); } } }