func selectTablesSQL(tx database.Tx) ([]string, error) {
	return query.SelectStrings(tx, StmtSelectTableSQL)
}
Return a list of SQL statements that can be used to create all tables in the
database.
package schema
import (
	"io/ioutil"
	"github.com/pkg/errors"
	"github.com/spoke-d/thermionic/internal/db/database"
	"github.com/spoke-d/thermionic/internal/db/query"
	"github.com/spoke-d/thermionic/internal/fsys"
)
const StmtSchemaTableExists = `
SELECT COUNT(name) FROM sqlite_master WHERE type = 'table' AND name = 'schema'
`
const StmtCreateTable = `
CREATE TABLE schema (
    id         INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    version    INTEGER NOT NULL,
    updated_at DATETIME NOT NULL,
    UNIQUE (version)
)
`
const StmtSelectSchemaVersions = `
SELECT version FROM schema ORDER BY version
`
const StmtSelectTableSQL = `
SELECT sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name != 'schema' ORDER BY name
`
const StmtInsertSchemaVersion = `
INSERT INTO schema (version, updated_at) VALUES (?, strftime("%s"))
`
const StmtDump = `
INSERT INTO schema (version, updated_at) VALUES (%d, strftime("%%s"))
`
func SchemaTableExists(tx database.Tx) (bool, error) {
	rows, err := tx.Query(StmtSchemaTableExists)
	if err != nil {
		return false, errors.WithStack(err)
	}
	defer rows.Close()
	if !rows.Next() {
		return false, errors.Errorf("schema table query returned no rows")
	}
	var count int
	if err := rows.Scan(&count); err != nil {
		return false, errors.WithStack(err)
	}
	return count == 1, nil
}
func createSchemaTable(tx database.Tx) error {
	_, err := tx.Exec(StmtCreateTable)
	return errors.WithStack(err)
}
func selectSchemaVersions(tx database.Tx) ([]int, error) {
	return query.SelectIntegers(tx, StmtSelectSchemaVersions)
}