1
0

32 lines
905 B
Go

package common
import (
"zombiezen.com/go/sqlite"
"zombiezen.com/go/sqlite/sqlitex"
)
// Represents an opcode in the database.
type Opcode struct {
ID int64 `db:"id"`
VersionRange1 int16 `db:"version_range1"`
VersionRange2 int16 `db:"version_range2"`
Name string `db:"name"`
Opcode int16 `db:"opcode"`
TableDataVersion int16 `db:"table_data_version"`
}
// Creates the opcodes table in the database.
func CreateOpcodesTable(conn *sqlite.Conn) error {
return sqlitex.ExecScript(conn, `
CREATE TABLE IF NOT EXISTS opcodes (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
version_range1 INTEGER NOT NULL DEFAULT 0,
version_range2 INTEGER NOT NULL DEFAULT 0,
name TEXT NOT NULL DEFAULT '',
opcode INTEGER NOT NULL DEFAULT 0,
table_data_version INTEGER NOT NULL DEFAULT 1,
UNIQUE(version_range1, name, version_range2)
);
`)
}