Add table applications and devices_applications for tracking installed applications per device and total installed application count.

This commit is contained in:
Mosen
2016-07-11 16:17:04 +10:00
parent 841c4eea79
commit fba935db87
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
DROP TABLE IF EXISTS devices_applications;
DROP INDEX IF EXISTS idx_application_name;
DROP INDEX IF EXISTS idx_application_identifier;
DROP TABLE IF EXISTS applications;

View File

@@ -0,0 +1,26 @@
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Cant have a unique constraint on name or identifier because it is possible to have multiple versions of the same
-- bundle installed.
CREATE TABLE IF NOT EXISTS applications (
application_uuid uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text NOT NULL,
identifier text,
short_version text,
version text,
bundle_size integer,
dynamic_size integer,
is_validated bool,
install_count integer DEFAULT 1,
UNIQUE(name, version)
);
CREATE INDEX IF NOT EXISTS idx_application_name ON applications (name);
CREATE INDEX IF NOT EXISTS idx_application_identifier ON applications (identifier);
CREATE TABLE IF NOT EXISTS devices_applications (
device_uuid uuid REFERENCES devices(device_uuid) ON DELETE CASCADE,
application_uuid uuid REFERENCES applications(application_uuid) ON DELETE CASCADE
);