MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/golang-samples / migrateDB

Function migrateDB

cloudsql/postgres/database-sql/cloudsql.go:50–59  ·  view source on GitHub ↗

migrateDB creates the votes table if it does not already exist.

(db *sql.DB)

Source from the content-addressed store, hash-verified

48
49// migrateDB creates the votes table if it does not already exist.
50func migrateDB(db *sql.DB) error {
51 createVotes := `CREATE TABLE IF NOT EXISTS votes (
52 id SERIAL NOT NULL,
53 created_at timestamp NOT NULL,
54 candidate VARCHAR(6) NOT NULL,
55 PRIMARY KEY (id)
56 );`
57 _, err := db.Exec(createVotes)
58 return err
59}
60
61// recentVotes returns the last five votes cast.
62func recentVotes(db *sql.DB) ([]vote, error) {

Callers 1

mustConnectFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected