Skip to content

Commit

Permalink
create constants for table and column names
Browse files Browse the repository at this point in the history
  • Loading branch information
crschardt committed Dec 21, 2023
1 parent c9b6c1e commit 725a813
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* <p>You can use multiple SQL statements in one migration step as long as you separate them with a
* semicolon (;).
*/
public final class SqlMigrations {
public static final String[] SQL = {
public final class DatabaseSchema {

public static final String[] migrations = {
// #1 - initial schema
"CREATE TABLE IF NOT EXISTS global (\n"
+ " filename TINYTEXT PRIMARY KEY,\n"
Expand All @@ -41,4 +42,24 @@ public final class SqlMigrations {
"ALTER TABLE cameras ADD COLUMN otherpaths_json TEXT NOT NULL DEFAULT '[]';",
// add future migrations here
};

// Constants for the tables and column to help prevent typos in SQL queries
// Update these tables to keep them constant with the current schema
public final class Tables {
// These constants should match the current SQL name of each table
public static final String GLOBAL = "global";
public static final String CAMERAS = "cameras";
}

public final class Columns {
// These constants should match the current SQL name of each column
static final String GLB_FILENAME = "filename";
static final String GLB_CONTENTS = "contents";

static final String CAM_UNIQUE_NAME = "unique_name";
static final String CAM_CONFIG_JSON = "config_json";
static final String CAM_DRIVERMODE_JSON = "drivermode_json";
static final String CAM_PIPELINE_JSONS = "pipeline_jsons";
static final String CAM_OTHERPATHS_JSON = "otherpaths_json";
}
}

0 comments on commit 725a813

Please sign in to comment.