chore(pytest): Create and use fixture of Fresh DB instead of migrations for testing

ref: #770
This commit is contained in:
2025-05-23 14:30:01 +09:30
parent 95281d35eb
commit 06ad1fec5e
7 changed files with 300 additions and 1 deletions

View File

@ -6,6 +6,7 @@
],
"python.testing.pytestArgs": [
"--override-ini", "addopts=",
"--no-migrations",
"app",
],
"python.testing.unittestEnabled": false,

View File

@ -80,6 +80,9 @@ FEATURE_FLAG_OVERRIDES = None # Feature Flags to override fetched feature flags
# PROMETHEUS_METRICS_EXPORT_PORT = 8010
# PROMETHEUS_METRICS_EXPORT_ADDRESS = ''
FIXTURE_DIRS = [
os.path.join(BASE_DIR, 'fixtures')
]
LOG_FILES = { # defaults for devopment. docker includes settings has correct locations
"centurion": "log/centurion.log",

View File

@ -1,7 +1,11 @@
import datetime
import pytest
import os
import sqlite3
import sys
from django.core.management import call_command
from django.conf import settings
from django.test import (
TestCase
)
@ -10,6 +14,32 @@ from access.models.tenant import Tenant
@pytest.fixture(scope="session", autouse = True)
def load_sqlite_fixture(django_db_setup, django_db_blocker):
"""
Load the SQLite database from an SQL dump file.
This runs during test setup and loads the schema and data via SQLite directly.
"""
db_path = settings.DATABASES['default']['NAME']
sql_file_path = os.path.join('app/fixtures', 'fresh_db.sql')
with django_db_blocker.unblock():
with open(sql_file_path, 'r') as f:
sql_script = f.read()
conn = sqlite3.connect(db_path)
try:
conn.executescript(sql_script)
finally:
conn.close()
with django_db_blocker.unblock():
call_command('loaddata','fresh_db')
def pytest_configure(config):
print("\n--- Pytest Launch Arguments ---")

View File

@ -0,0 +1,17 @@
[
{
"model": "settings.appsettings",
"pk": 1,
"fields": {
"created": "2025-05-23T08:33:31.728Z",
"modified": "2025-05-23T08:33:31Z",
"owner_organization": null,
"device_model_is_global": false,
"device_type_is_global": false,
"manufacturer_is_global": false,
"software_is_global": false,
"software_categories_is_global": false,
"global_organization": null
}
}
]

224
app/fixtures/fresh_db.sql Normal file
View File

@ -0,0 +1,224 @@
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "django_migrations" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app" varchar(255) NOT NULL, "name" varchar(255) NOT NULL, "applied" datetime NOT NULL);
CREATE TABLE IF NOT EXISTS "auth_group_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "group_id" integer NOT NULL REFERENCES "auth_group" ("id") DEFERRABLE INITIALLY DEFERRED, "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "auth_user_groups" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "group_id" integer NOT NULL REFERENCES "auth_group" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "auth_user_user_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "django_content_type" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "app_label" varchar(100) NOT NULL, "model" varchar(100) NOT NULL);
CREATE TABLE IF NOT EXISTS "auth_permission" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "codename" varchar(100) NOT NULL, "name" varchar(255) NOT NULL);
CREATE TABLE IF NOT EXISTS "auth_group" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(150) NOT NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "auth_user" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "password" varchar(128) NOT NULL, "last_login" datetime NULL, "is_superuser" bool NOT NULL, "username" varchar(150) NOT NULL UNIQUE, "last_name" varchar(150) NOT NULL, "email" varchar(254) NOT NULL, "is_staff" bool NOT NULL, "is_active" bool NOT NULL, "date_joined" datetime NOT NULL, "first_name" varchar(150) NOT NULL);
CREATE TABLE IF NOT EXISTS "access_tenant" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL UNIQUE, "model_notes" text NULL, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "manager_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_teamusers" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "manager" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "settings_externallink" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(30) NOT NULL UNIQUE, "template" varchar(180) NOT NULL, "colour" varchar(80) NULL, "devices" bool NOT NULL, "software" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "cluster" bool NOT NULL, "service" bool NOT NULL, "button_text" varchar(30) NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "itim_cluster_devices" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "cluster_id" integer NOT NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_cluster_nodes" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "cluster_id" integer NOT NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_service_dependent_service" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "from_service_id" integer NOT NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED, "to_service_id" integer NOT NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_service_port" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "service_id" integer NOT NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED, "port_id" integer NOT NULL REFERENCES "itim_port" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_cluster" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL, "slug" varchar(50) NOT NULL, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "created" datetime NOT NULL, "modified" datetime NOT NULL, "cluster_type_id" integer NULL REFERENCES "itim_clustertype" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_cluster_id" integer NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_clustertype" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_port" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "number" integer NOT NULL, "description" varchar(80) NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "protocol" varchar(3) NOT NULL);
CREATE TABLE IF NOT EXISTS "itim_service" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "is_template" bool NOT NULL, "name" varchar(50) NOT NULL, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "config_key_variable" varchar(50) NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "cluster_id" integer NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "template_id" integer NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledgebasecategory_target_team" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "knowledgebasecategory_id" bigint NOT NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledgebase_responsible_teams" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "knowledgebase_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledgebase_target_team" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "knowledgebase_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project_team_members" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "project_id" integer NOT NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticket_assigned_teams" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticket_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticket_assigned_users" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticket_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticket_subscribed_teams" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticket_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "team_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticket_subscribed_users" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticket_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgroups_hosts" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "configgroups_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgrouphosts" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "group_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED, "host_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgroups" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_id" integer NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgroupsoftware" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "action" integer NULL, "config_group_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED, "version_id" integer NULL REFERENCES "itam_softwareversion" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_history" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "after" text NULL CHECK ((JSON_VALID("after") OR "after" IS NULL)), "action" integer NULL, "item_pk" integer NULL, "item_class" varchar(50) NULL, "item_parent_pk" integer NULL, "item_parent_class" varchar(50) NULL, "user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "before" text NULL CHECK ((JSON_VALID("before") OR "before" IS NULL)));
CREATE TABLE IF NOT EXISTS "core_manufacturer" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_notes" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "note" text NOT NULL, "config_group_id" integer NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED, "operatingsystem_id" integer NULL REFERENCES "itam_operatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED, "usercreated_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "usermodified_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "service_id" integer NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_relatedtickets" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "how_related" integer NOT NULL, "from_ticket_id_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "to_ticket_id_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticket" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "status" integer NOT NULL, "title" varchar(100) NOT NULL UNIQUE, "description" text NOT NULL, "urgency" integer NULL, "impact" integer NULL, "priority" integer NULL, "external_ref" integer NULL, "external_system" integer NULL, "ticket_type" integer NOT NULL, "is_deleted" bool NOT NULL, "date_closed" datetime NULL, "planned_start_date" datetime NULL, "planned_finish_date" datetime NULL, "estimate" integer NOT NULL, "real_start_date" datetime NULL, "real_finish_date" datetime NULL, "milestone_id" integer NULL REFERENCES "project_management_projectmilestone" ("id") DEFERRABLE INITIALLY DEFERRED, "opened_by_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "project_id" integer NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED, "category_id" integer NULL REFERENCES "core_ticketcategory" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_ticket_id" integer NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcategory" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "change" bool NOT NULL, "incident" bool NOT NULL, "problem" bool NOT NULL, "project_task" bool NOT NULL, "request" bool NOT NULL, "runbook_id" integer NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_id" integer NULL REFERENCES "core_ticketcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcomment" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "external_ref" integer NULL, "external_system" integer NULL, "comment_type" integer NOT NULL, "body" text NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "private" bool NOT NULL, "duration" integer NOT NULL, "is_template" bool NOT NULL, "source" integer NOT NULL, "status" integer NOT NULL, "date_closed" datetime NULL, "planned_start_date" datetime NULL, "planned_finish_date" datetime NULL, "real_start_date" datetime NULL, "real_finish_date" datetime NULL, "responsible_team_id" integer NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED, "responsible_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "ticket_id" integer NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "category_id" integer NULL REFERENCES "core_ticketcommentcategory" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_id" integer NULL REFERENCES "core_ticketcomment" ("id") DEFERRABLE INITIALLY DEFERRED, "template_id" integer NULL REFERENCES "core_ticketcomment" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcommentcategory" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "comment" bool NOT NULL, "notification" bool NOT NULL, "solution" bool NOT NULL, "task" bool NOT NULL, "runbook_id" integer NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_id" integer NULL REFERENCES "core_ticketcommentcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketlinkeditem" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "item_type" integer NOT NULL, "item" integer NOT NULL, "ticket_id" integer NOT NULL REFERENCES "core_ticket" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicemodel" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "manufacturer_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicesoftware" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "action" integer NULL, "installed" datetime NULL, "device_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED, "installedversion_id" integer NULL REFERENCES "itam_softwareversion" ("id") DEFERRABLE INITIALLY DEFERRED, "version_id" integer NULL REFERENCES "itam_softwareversion" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicetype" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operatingsystem" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "publisher_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operatingsystemversion" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "operating_system_id" integer NOT NULL REFERENCES "itam_operatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_softwarecategory" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_softwareversion" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_deviceoperatingsystem" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "version" varchar(15) NOT NULL, "installdate" datetime NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "operating_system_version_id" integer NOT NULL REFERENCES "itam_operatingsystemversion" ("id") DEFERRABLE INITIALLY DEFERRED, "device_id" integer NOT NULL UNIQUE REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_device" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "serial_number" varchar(50) NULL UNIQUE, "inventorydate" datetime NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "device_model_id" integer NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED, "device_type_id" integer NULL REFERENCES "itam_devicetype" ("id") DEFERRABLE INITIALLY DEFERRED, "config" text NULL CHECK ((JSON_VALID("config") OR "config" IS NULL)), "is_virtual" bool NOT NULL, "uuid" varchar(50) NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "core_model_notes" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "content" text NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "created_by_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "modified_by_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_config_group_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_team_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_manufacturer_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "settings_external_link_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "settings_externallink" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_model_history" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "is_global" bool NOT NULL, "before" text NULL CHECK ((JSON_VALID("before") OR "before" IS NULL)), "after" text NULL CHECK ((JSON_VALID("after") OR "after" IS NULL)), "action" integer NULL, "created" datetime NOT NULL, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_manufacturer_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcategory_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_ticketcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcommentcategory_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_ticketcommentcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "settings_appsettings_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "settings_appsettings" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "settings_externallink_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "settings_externallink" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project" ("is_global" bool NOT NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(100) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "external_ref" integer NULL, "external_system" integer NULL, "description" text NULL, "priority" integer NULL, "code" varchar(25) NULL UNIQUE, "planned_start_date" datetime NULL, "planned_finish_date" datetime NULL, "real_start_date" datetime NULL, "real_finish_date" datetime NULL, "is_deleted" bool NOT NULL, "manager_team_id" integer NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED, "manager_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "state_id" integer NULL REFERENCES "project_management_projectstate" ("id") DEFERRABLE INITIALLY DEFERRED, "project_type_id" integer NULL REFERENCES "project_management_projecttype" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projectmilestone" ("is_global" bool NOT NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "modified" datetime NOT NULL, "name" varchar(100) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "description" text NULL, "start_date" datetime NULL, "finish_date" datetime NULL, "created" datetime NOT NULL, "project_id" integer NOT NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projectstate" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "is_completed" bool NOT NULL, "runbook_id" integer NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projecttype" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "name" varchar(50) NOT NULL UNIQUE, "runbook_id" integer NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project_milestone_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projectmilestone" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project_state_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projectstate" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project_type_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projecttype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_project_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projectmilestone_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projectmilestone" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projectstate_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projectstate" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "project_management_projecttype_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "project_management_projecttype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_cluster_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_cluster_type_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_clustertype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_port_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_port" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_service_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_cluster_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_cluster" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_clustertype_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_clustertype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_port_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_port" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_service_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itim_service" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_device_mdel_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_device_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_device_type_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicetype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operating_system_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_operatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operating_system_version_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_operatingsystemversion" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_software_category_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_softwarecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_software_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_software_version_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_softwareversion" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_device_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_device" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicemodel_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicemodel" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicetype_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_devicetype" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operatingsystem_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_operatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_operatingsystemversion_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_operatingsystemversion" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_softwarecategory_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_softwarecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_software_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_softwareversion_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "itam_softwareversion" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_deviceoperatingsystem_history" ("devicehistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "itam_device_history" ("modelhistory_ptr_id") DEFERRABLE INITIALLY DEFERRED, "child_model_id" integer NULL REFERENCES "itam_deviceoperatingsystem" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_devicesoftware_history" ("devicehistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "itam_device_history" ("modelhistory_ptr_id") DEFERRABLE INITIALLY DEFERRED, "child_model_id" integer NULL REFERENCES "itam_devicesoftware" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgroups_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "config_management_configgroups" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgrouphosts_history" ("configgroupshistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "config_management_configgroups_history" ("modelhistory_ptr_id") DEFERRABLE INITIALLY DEFERRED, "child_model_id" integer NULL REFERENCES "config_management_configgrouphosts" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "config_management_configgroupsoftware_history" ("configgroupshistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "config_management_configgroups_history" ("modelhistory_ptr_id") DEFERRABLE INITIALLY DEFERRED, "child_model_id" integer NULL REFERENCES "config_management_configgroupsoftware" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledgebase" ("is_global" bool NOT NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(50) NOT NULL, "summary" text NULL, "content" text NULL, "release_date" datetime NULL, "expiry_date" datetime NULL, "public" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "responsible_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "target_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "category_id" bigint NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledgebasecategory" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "is_global" bool NOT NULL, "model_notes" text NULL, "name" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "target_user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_category_id" integer NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_modelknowledgebasearticle" ("is_global" bool NOT NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "model" varchar(50) NOT NULL, "model_pk" integer NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "article_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledge_base_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledge_base_category_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledge_base_category_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "assistance_knowledgebasecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "assistance_knowledge_base_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "assistance_knowledgebase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_team_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_team" ("group_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcategory_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_ticketcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcommentcategory_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "core_ticketcommentcategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_entity_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_entity_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_role" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(30) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_role_permissions" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "role_id" integer NOT NULL REFERENCES "access_role" ("id") DEFERRABLE INITIALLY DEFERRED, "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_role_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_role" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_role_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_role" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_contact" ("person_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_person" ("entity_ptr_id") DEFERRABLE INITIALLY DEFERRED, "directory" bool NOT NULL, "email" varchar(254) NOT NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "core_ticketbase_assigned_to" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticketbase_id" integer NOT NULL REFERENCES "core_ticketbase" ("id") DEFERRABLE INITIALLY DEFERRED, "entity_id" integer NOT NULL REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketbase_subscribed_to" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticketbase_id" integer NOT NULL REFERENCES "core_ticketbase" ("id") DEFERRABLE INITIALLY DEFERRED, "entity_id" integer NOT NULL REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcommentsolution" ("ticketcommentbase_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_ticketcommentbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itim_slmticket" ("ticketbase_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_ticketbase" ("id") DEFERRABLE INITIALLY DEFERRED, "ttr" integer NOT NULL, "tto" integer NOT NULL);
CREATE TABLE IF NOT EXISTS "itim_requestticket" ("slmticket_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "itim_slmticket" ("ticketbase_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_checkin" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "version" text NULL, "deployment_id" varchar(64) NOT NULL, "feature" text NOT NULL, "created" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_featureflag" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL, "description" text NULL, "enabled" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_feature_flag_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_featureflag" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_feature_flag_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_featureflag" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_softwareenablefeatureflag" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "enabled" bool NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "software_id" integer NOT NULL REFERENCES "itam_software" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_githubrepository" ("gitrepository_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "devops_gitrepository" ("id") DEFERRABLE INITIALLY DEFERRED, "wiki" bool NOT NULL, "issues" bool NOT NULL, "sponsorships" bool NOT NULL, "preserve_this_repository" bool NOT NULL, "discussions" bool NOT NULL, "projects" bool NOT NULL);
CREATE TABLE IF NOT EXISTS "devops_gitlabrepository" ("gitrepository_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "devops_gitrepository" ("id") DEFERRABLE INITIALLY DEFERRED, "visibility" integer NOT NULL);
CREATE TABLE IF NOT EXISTS "devops_github_repository_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_githubrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_gitlab_repository_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitlabrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_git_group_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_github_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_githubrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_gitlab_repository_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitlabrepository" ("gitrepository_ptr_id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_git_group_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "devops_gitrepository" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "provider" integer NOT NULL, "path" varchar(80) NOT NULL, "name" varchar(80) NOT NULL, "description" text NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "git_group_id" integer NOT NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "provider_id" integer NULL);
CREATE TABLE IF NOT EXISTS "devops_gitgroup" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "provider" integer NOT NULL, "name" varchar(80) NOT NULL, "path" varchar(80) NOT NULL, "description" text NULL, "created" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "modified" datetime NOT NULL, "provider_pk" integer NULL, "parent_group_id" integer NULL REFERENCES "devops_gitgroup" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_team" ("group_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "auth_group" ("id") DEFERRABLE INITIALLY DEFERRED, "is_global" bool NOT NULL, "model_notes" text NULL, "team_name" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_organization_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_organization_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "settings_usersettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "default_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "timezone" varchar(32) NOT NULL, "browser_mode" integer NOT NULL);
CREATE TABLE IF NOT EXISTS "settings_appsettings" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "device_model_is_global" bool NOT NULL, "device_type_is_global" bool NOT NULL, "manufacturer_is_global" bool NOT NULL, "software_is_global" bool NOT NULL, "software_categories_is_global" bool NOT NULL, "global_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "owner_organization_id" integer NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "itam_software" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "publisher_id" integer NULL REFERENCES "core_manufacturer" ("id") DEFERRABLE INITIALLY DEFERRED, "category_id" integer NULL REFERENCES "itam_softwarecategory" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "access_company" ("entity_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED, "name" varchar(80) NOT NULL);
CREATE TABLE IF NOT EXISTS "access_entity" ("is_global" bool NOT NULL, "model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "entity_type" varchar(30) NOT NULL);
CREATE TABLE IF NOT EXISTS "access_person" ("entity_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED, "f_name" varchar(64) NOT NULL, "l_name" varchar(64) NOT NULL, "dob" date NULL, "m_name" varchar(100) NULL);
CREATE TABLE IF NOT EXISTS "core_ticketcommentaction" ("ticketcommentbase_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_ticketcommentbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketbase" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "external_system" integer NULL, "external_ref" integer NULL, "ticket_type" varchar(30) NOT NULL, "status" integer NOT NULL, "title" varchar(150) NOT NULL UNIQUE, "description" text NULL, "private" bool NOT NULL, "urgency" integer NULL, "impact" integer NULL, "priority" integer NULL, "planned_start_date" datetime NULL, "planned_finish_date" datetime NULL, "real_start_date" datetime NULL, "real_finish_date" datetime NULL, "is_deleted" bool NOT NULL, "is_solved" bool NOT NULL, "date_solved" datetime NULL, "is_closed" bool NOT NULL, "date_closed" datetime NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "category_id" integer NULL REFERENCES "core_ticketcategory" ("id") DEFERRABLE INITIALLY DEFERRED, "milestone_id" integer NULL REFERENCES "project_management_projectmilestone" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "project_id" integer NULL REFERENCES "project_management_project" ("id") DEFERRABLE INITIALLY DEFERRED, "opened_by_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_ticket_id" integer NULL REFERENCES "core_ticketbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_ticketcommentbase" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "external_ref" integer NULL, "external_system" integer NULL, "comment_type" varchar(30) NOT NULL, "body" text NULL, "private" bool NOT NULL, "duration" integer NOT NULL, "estimation" integer NOT NULL, "is_template" bool NOT NULL, "source" integer NOT NULL, "is_closed" bool NOT NULL, "date_closed" datetime NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "category_id" integer NULL REFERENCES "core_ticketcommentcategory" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "ticket_id" integer NOT NULL REFERENCES "core_ticketbase" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NULL REFERENCES "access_entity" ("id") DEFERRABLE INITIALLY DEFERRED, "parent_id" integer NULL REFERENCES "core_ticketcommentbase" ("id") DEFERRABLE INITIALLY DEFERRED, "template_id" integer NULL REFERENCES "core_ticketcommentbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "accounting_assetbase" ("model_notes" text NULL, "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "asset_number" varchar(30) NULL UNIQUE, "serial_number" varchar(30) NULL UNIQUE, "asset_type" varchar(30) NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "accounting_assetbase_history" ("modelhistory_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_history" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "accounting_assetbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "accounting_assetbase_notes" ("modelnotes_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "core_model_notes" ("id") DEFERRABLE INITIALLY DEFERRED, "model_id" integer NOT NULL REFERENCES "accounting_assetbase" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "django_admin_log" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "object_id" text NULL, "object_repr" varchar(200) NOT NULL, "action_flag" smallint unsigned NOT NULL CHECK ("action_flag" >= 0), "change_message" text NOT NULL, "content_type_id" integer NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "action_time" datetime NOT NULL);
CREATE TABLE IF NOT EXISTS "api_authtoken" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "note" varchar(50) NULL, "token" varchar(64) NOT NULL UNIQUE, "expires" datetime NOT NULL, "created" datetime NOT NULL, "modified" datetime NOT NULL, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "core_audithistory" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "model_notes" text NULL, "created" datetime NOT NULL, "before" text NULL CHECK ((JSON_VALID("before") OR "before" IS NULL)), "after" text NULL CHECK ((JSON_VALID("after") OR "after" IS NULL)), "action" integer NULL, "content_type_id" integer NOT NULL REFERENCES "django_content_type" ("id") DEFERRABLE INITIALLY DEFERRED, "organization_id" integer NOT NULL REFERENCES "access_tenant" ("id") DEFERRABLE INITIALLY DEFERRED, "user_id" integer NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE TABLE IF NOT EXISTS "django_celery_results_groupresult" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "group_id" varchar(255) NOT NULL UNIQUE, "date_created" datetime NOT NULL, "date_done" datetime NOT NULL, "content_type" varchar(128) NOT NULL, "content_encoding" varchar(64) NOT NULL, "result" text NULL);
CREATE TABLE IF NOT EXISTS "django_celery_results_chordcounter" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "sub_tasks" text NOT NULL, "count" integer unsigned NOT NULL CHECK ("count" >= 0), "group_id" varchar(255) NOT NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "django_celery_results_taskresult" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "task_id" varchar(255) NOT NULL UNIQUE, "status" varchar(50) NOT NULL, "content_type" varchar(128) NOT NULL, "content_encoding" varchar(64) NOT NULL, "result" text NULL, "date_done" datetime NOT NULL, "traceback" text NULL, "meta" text NULL, "task_args" text NULL, "task_kwargs" text NULL, "task_name" varchar(255) NULL, "date_created" datetime NOT NULL, "worker" varchar(100) NULL, "periodic_task_name" varchar(255) NULL);
CREATE TABLE IF NOT EXISTS "human_resources_employee" ("contact_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "access_contact" ("person_ptr_id") DEFERRABLE INITIALLY DEFERRED, "employee_number" integer NOT NULL UNIQUE);
CREATE TABLE IF NOT EXISTS "itam_itamassetbase" ("assetbase_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "accounting_assetbase" ("id") DEFERRABLE INITIALLY DEFERRED, "itam_type" varchar(30) NOT NULL);
CREATE TABLE IF NOT EXISTS "django_session" ("session_key" varchar(40) NOT NULL PRIMARY KEY, "session_data" text NOT NULL, "expire_date" datetime NOT NULL);
CREATE TABLE IF NOT EXISTS "social_auth_association" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "server_url" varchar(255) NOT NULL, "handle" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "issued" integer NOT NULL, "lifetime" integer NOT NULL, "assoc_type" varchar(64) NOT NULL);
CREATE TABLE IF NOT EXISTS "social_auth_code" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "email" varchar(254) NOT NULL, "code" varchar(32) NOT NULL, "verified" bool NOT NULL, "timestamp" datetime NOT NULL);
CREATE TABLE IF NOT EXISTS "social_auth_nonce" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "server_url" varchar(255) NOT NULL, "timestamp" integer NOT NULL, "salt" varchar(65) NOT NULL);
CREATE TABLE IF NOT EXISTS "social_auth_usersocialauth" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "provider" varchar(32) NOT NULL, "uid" varchar(255) NOT NULL, "user_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "created" datetime NOT NULL, "modified" datetime NOT NULL, "extra_data" text NOT NULL CHECK ((JSON_VALID("extra_data") OR "extra_data" IS NULL)));
CREATE TABLE IF NOT EXISTS "social_auth_partial" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "token" varchar(32) NOT NULL, "next_step" smallint unsigned NOT NULL CHECK ("next_step" >= 0), "backend" varchar(32) NOT NULL, "timestamp" datetime NOT NULL, "data" text NOT NULL CHECK ((JSON_VALID("data") OR "data" IS NULL)));
DELETE FROM sqlite_sequence;
INSERT INTO sqlite_sequence VALUES('django_migrations',156);
INSERT INTO sqlite_sequence VALUES('django_content_type',147);
INSERT INTO sqlite_sequence VALUES('auth_permission',633);
INSERT INTO sqlite_sequence VALUES('auth_group',0);
INSERT INTO sqlite_sequence VALUES('auth_user',0);
INSERT INTO sqlite_sequence VALUES('settings_externallink',0);
INSERT INTO sqlite_sequence VALUES('itim_cluster',0);
INSERT INTO sqlite_sequence VALUES('itim_clustertype',0);
INSERT INTO sqlite_sequence VALUES('itim_port',0);
INSERT INTO sqlite_sequence VALUES('itim_service',0);
INSERT INTO sqlite_sequence VALUES('config_management_configgrouphosts',0);
INSERT INTO sqlite_sequence VALUES('config_management_configgroups',0);
INSERT INTO sqlite_sequence VALUES('config_management_configgroupsoftware',0);
INSERT INTO sqlite_sequence VALUES('core_history',0);
INSERT INTO sqlite_sequence VALUES('core_manufacturer',0);
INSERT INTO sqlite_sequence VALUES('core_notes',0);
INSERT INTO sqlite_sequence VALUES('core_relatedtickets',0);
INSERT INTO sqlite_sequence VALUES('core_ticket',0);
INSERT INTO sqlite_sequence VALUES('core_ticketcategory',0);
INSERT INTO sqlite_sequence VALUES('core_ticketcomment',0);
INSERT INTO sqlite_sequence VALUES('core_ticketcommentcategory',0);
INSERT INTO sqlite_sequence VALUES('core_ticketlinkeditem',0);
INSERT INTO sqlite_sequence VALUES('itam_devicemodel',0);
INSERT INTO sqlite_sequence VALUES('itam_devicesoftware',0);
INSERT INTO sqlite_sequence VALUES('itam_devicetype',0);
INSERT INTO sqlite_sequence VALUES('itam_operatingsystem',0);
INSERT INTO sqlite_sequence VALUES('itam_operatingsystemversion',0);
INSERT INTO sqlite_sequence VALUES('itam_softwarecategory',0);
INSERT INTO sqlite_sequence VALUES('itam_softwareversion',0);
INSERT INTO sqlite_sequence VALUES('itam_deviceoperatingsystem',0);
INSERT INTO sqlite_sequence VALUES('itam_device',0);
INSERT INTO sqlite_sequence VALUES('project_management_project',0);
INSERT INTO sqlite_sequence VALUES('project_management_projectmilestone',0);
INSERT INTO sqlite_sequence VALUES('project_management_projectstate',0);
INSERT INTO sqlite_sequence VALUES('project_management_projecttype',0);
INSERT INTO sqlite_sequence VALUES('assistance_knowledgebase',0);
INSERT INTO sqlite_sequence VALUES('assistance_knowledgebasecategory',0);
INSERT INTO sqlite_sequence VALUES('devops_gitrepository',0);
INSERT INTO sqlite_sequence VALUES('devops_gitgroup',0);
INSERT INTO sqlite_sequence VALUES('settings_usersettings',0);
INSERT INTO sqlite_sequence VALUES('settings_appsettings',1);
INSERT INTO sqlite_sequence VALUES('itam_software',0);
INSERT INTO sqlite_sequence VALUES('access_entity',0);
INSERT INTO sqlite_sequence VALUES('core_ticketbase',0);
INSERT INTO sqlite_sequence VALUES('core_ticketcommentbase',0);
INSERT INTO sqlite_sequence VALUES('django_admin_log',0);
INSERT INTO sqlite_sequence VALUES('django_celery_results_chordcounter',0);
INSERT INTO sqlite_sequence VALUES('django_celery_results_taskresult',0);
INSERT INTO sqlite_sequence VALUES('social_auth_association',0);
INSERT INTO sqlite_sequence VALUES('social_auth_code',0);
INSERT INTO sqlite_sequence VALUES('social_auth_nonce',0);
INSERT INTO sqlite_sequence VALUES('social_auth_usersocialauth',0);
INSERT INTO sqlite_sequence VALUES('social_auth_partial',0);
COMMIT;

View File

@ -35,6 +35,30 @@ docs: docs-lint
mkdocs build --clean
fixtures:
${ACTIVATE_VENV}
mv app/db.sqlite3 app/db.sqlite3-current
if [ ! -f app/db.sqlite3-current ]; then echo "failed to save current db"; exit 1; fi;
python app/manage.py migrate;
python app/manage.py dumpdata \
--natural-foreign \
--natural-primary \
--exclude=contenttypes \
--exclude=auth.permission \
--indent 2 > app/fixtures/fresh_db.json;
sqlite3 app/db.sqlite3 .dump | \
grep -a -v 'INSERT INTO django_migrations' | \
grep -a -v 'INSERT INTO django_content_type' | \
grep -a -v 'INSERT INTO auth_permission' | \
grep -a -v 'INSERT INTO settings_appsettings' | \
grep -a -v 'CREATE UNIQUE INDEX' | \
grep -a -v 'CREATE INDEX' \
> app/fixtures/fresh_db.sql;
rm -f app/db.sqlite3
if [ ! -f app/db.sqlite3 ]; then cp app/db.sqlite3-current app/db.sqlite3; fi;
if [ -f app/db.sqlite3 ]; then rm -f app/db.sqlite3-current; fi;
lint: markdown-mkdocs-lint

View File

@ -1027,7 +1027,7 @@ redefining-builtins-modules = ["six.moves", "past.builtins", "future.builtins",
[tool.pytest.ini_options]
addopts = '--cov --cov-branch --cov-report term --tb=long --verbosity=2 --full-trace --showlocals app'
addopts = '--no-migrations --cov --cov-branch --cov-report term --tb=long --verbosity=2 --full-trace --showlocals app'
DJANGO_SETTINGS_MODULE = 'centurion.settings'