diff --git a/migrations/201607110001_applications_down.sql b/migrations/201607110001_applications_down.sql new file mode 100644 index 00000000..ebcb8230 --- /dev/null +++ b/migrations/201607110001_applications_down.sql @@ -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; \ No newline at end of file diff --git a/migrations/201607110001_applications_up.sql b/migrations/201607110001_applications_up.sql new file mode 100644 index 00000000..00f6f65a --- /dev/null +++ b/migrations/201607110001_applications_up.sql @@ -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 +); +