001/* 002 * Copyright (C) Photon Vision. 003 * 004 * This program is free software: you can redistribute it and/or modify 005 * it under the terms of the GNU General Public License as published by 006 * the Free Software Foundation, either version 3 of the License, or 007 * (at your option) any later version. 008 * 009 * This program is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 * GNU General Public License for more details. 013 * 014 * You should have received a copy of the GNU General Public License 015 * along with this program. If not, see <https://www.gnu.org/licenses/>. 016 */ 017 018package org.photonvision.common.configuration; 019 020/** 021 * Add migrations by adding the SQL commands for each migration sequentially to this array. DO NOT 022 * edit or delete existing SQL commands. That will lead to producing an incompatible database. 023 * 024 * <p>You can use multiple SQL statements in one migration step as long as you separate them with a 025 * semicolon (;). 026 */ 027public final class DatabaseSchema { 028 public static final String[] migrations = { 029 // #1 - initial schema 030 "CREATE TABLE IF NOT EXISTS global (\n" 031 + " filename TINYTEXT PRIMARY KEY,\n" 032 + " contents mediumtext NOT NULL\n" 033 + ");" 034 + "CREATE TABLE IF NOT EXISTS cameras (\n" 035 + " unique_name TINYTEXT PRIMARY KEY,\n" 036 + " config_json text NOT NULL,\n" 037 + " drivermode_json text NOT NULL,\n" 038 + " pipeline_jsons mediumtext NOT NULL\n" 039 + ");", 040 // #2 - add column otherpaths_json 041 "ALTER TABLE cameras ADD COLUMN otherpaths_json TEXT NOT NULL DEFAULT '[]';", 042 // add future migrations here 043 }; 044 045 // Constants for the tables and column to help prevent typos in SQL queries 046 // Update these tables to keep them constant with the current schema 047 public final class Tables { 048 // These constants should match the current SQL name of each table 049 public static final String GLOBAL = "global"; 050 public static final String CAMERAS = "cameras"; 051 } 052 053 public final class Columns { 054 // These constants should match the current SQL name of each column 055 static final String GLB_FILENAME = "filename"; 056 static final String GLB_CONTENTS = "contents"; 057 058 static final String CAM_UNIQUE_NAME = "unique_name"; 059 static final String CAM_CONFIG_JSON = "config_json"; 060 static final String CAM_DRIVERMODE_JSON = "drivermode_json"; 061 static final String CAM_PIPELINE_JSONS = "pipeline_jsons"; 062 static final String CAM_OTHERPATHS_JSON = "otherpaths_json"; 063 } 064}