generate ddl for database

This commit is contained in:
Eoin McAfee 2021-05-19 13:36:27 +01:00
parent d3acd5d823
commit 58824af15e
3 changed files with 55 additions and 0 deletions

View file

@ -156,6 +156,10 @@ var migrations = []struct {
name: "create-index-latest-repo",
stmt: createIndexLatestRepo,
},
{
name: "create-table-template",
stmt: createTableTemplate,
},
}
// Migrate performs the database migration. If the migration fails
@ -658,3 +662,18 @@ CREATE TABLE IF NOT EXISTS latest (
var createIndexLatestRepo = `
CREATE INDEX ix_latest_repo ON latest (latest_repo_id);
`
//
// 015_create_table_template.sql
//
var createTableTemplate = `
CREATE TABLE IF NOT EXISTS template (
template_id INTEGER PRIMARY KEY AUTO_INCREMENT
,template_name VARCHAR(500)
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name)
);
`

View file

@ -152,6 +152,10 @@ var migrations = []struct {
name: "create-index-latest-repo",
stmt: createIndexLatestRepo,
},
{
name: "create-table-template",
stmt: createTableTemplate,
},
}
// Migrate performs the database migration. If the migration fails
@ -636,3 +640,17 @@ CREATE TABLE IF NOT EXISTS latest (
var createIndexLatestRepo = `
CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
`
//
// 016_create_template_table.sql
//
var createTableTemplate = `
CREATE TABLE IF NOT EXISTS template (
template_id SERIAL PRIMARY KEY
,template_name TEXT UNIQUE
,template_data BYTEA
,template_created INTEGER
,template_updated INTEGER
);
`

View file

@ -152,6 +152,10 @@ var migrations = []struct {
name: "create-index-latest-repo",
stmt: createIndexLatestRepo,
},
{
name: "create-table-template",
stmt: createTableTemplate,
},
}
// Migrate performs the database migration. If the migration fails
@ -638,3 +642,17 @@ CREATE TABLE IF NOT EXISTS latest (
var createIndexLatestRepo = `
CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
`
//
// 015_create_template_table.sql
//
var createTableTemplate = `
CREATE TABLE IF NOT EXISTS template (
template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT UNIQUE
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
);
`