Let's write a few SQL strings for creating the tables for the preceding train, station, and route resources. We are going to create a project layout for this API. Create two directories called railAPI and dbutils in $GOPATH/src/github.com/git-user/chapter4.
Here, railAPI is our project source, and dbutils is our own package for handling database initialization utility functions. Follow these steps:
- Let's start with the dbutils/models.go file. Add three models each for train, station, and schedule in the models.go file:
package dbutilsconst train = ` CREATE TABLE IF NOT EXISTS train ( ID INTEGER PRIMARY KEY AUTOINCREMENT, DRIVER_NAME VARCHAR(64) NULL, OPERATING_STATUS BOOLEAN )`const station = ` CREATE TABLE IF NOT ...