update to support postgresql and add godocs
This commit is contained in:
38
db/migrations_postgres/20240912012927_init.sql
Normal file
38
db/migrations_postgres/20240912012927_init.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE IF NOT EXISTS "Inventory" (
|
||||
"Iid" BIGSERIAL PRIMARY KEY,
|
||||
"Name" TEXT NOT NULL,
|
||||
"Vcenter" TEXT NOT NULL,
|
||||
"VmId" TEXT,
|
||||
"EventKey" TEXT,
|
||||
"EventId" TEXT,
|
||||
"CreationTime" BIGINT,
|
||||
"DeletionTime" BIGINT,
|
||||
"ResourcePool" TEXT,
|
||||
"VmType" TEXT,
|
||||
"Datacenter" TEXT,
|
||||
"Cluster" TEXT,
|
||||
"Folder" TEXT,
|
||||
"ProvisionedDisk" REAL,
|
||||
"InitialVcpus" INTEGER,
|
||||
"InitialRam" INTEGER,
|
||||
"SrmPlaceholder" INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "Updates" (
|
||||
"Uid" BIGSERIAL PRIMARY KEY,
|
||||
"InventoryId" INTEGER,
|
||||
"UpdateTime" BIGINT,
|
||||
"UpdateType" TEXT NOT NULL,
|
||||
"NewVcpus" INTEGER,
|
||||
"NewRam" INTEGER,
|
||||
"NewResourcePool" TEXT
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE "Inventory";
|
||||
DROP TABLE "Updates";
|
||||
-- +goose StatementEnd
|
||||
11
db/migrations_postgres/20240912231739_extend_updates.sql
Normal file
11
db/migrations_postgres/20240912231739_extend_updates.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "EventKey" TEXT;
|
||||
ALTER TABLE "Updates" ADD COLUMN "EventId" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "EventKey";
|
||||
ALTER TABLE "Updates" DROP COLUMN "EventId";
|
||||
-- +goose StatementEnd
|
||||
21
db/migrations_postgres/20240913021038_events.sql
Normal file
21
db/migrations_postgres/20240913021038_events.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE IF NOT EXISTS "Events" (
|
||||
"Eid" BIGSERIAL PRIMARY KEY,
|
||||
"CloudId" TEXT NOT NULL,
|
||||
"Source" TEXT NOT NULL,
|
||||
"EventTime" BIGINT,
|
||||
"ChainId" TEXT NOT NULL,
|
||||
"VmId" TEXT,
|
||||
"EventKey" TEXT,
|
||||
"Datacenter" TEXT,
|
||||
"ComputeResource" TEXT,
|
||||
"UserName" TEXT,
|
||||
"Processed" INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE "Events";
|
||||
-- +goose StatementEnd
|
||||
17
db/migrations_postgres/20240913043145_extend_events.sql
Normal file
17
db/migrations_postgres/20240913043145_extend_events.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Events" RENAME COLUMN "Datacenter" TO "DatacenterName";
|
||||
ALTER TABLE "Events" RENAME COLUMN "ComputeResource" TO "ComputeResourceName";
|
||||
ALTER TABLE "Events" ADD COLUMN "DatacenterId" TEXT;
|
||||
ALTER TABLE "Events" ADD COLUMN "ComputeResourceId" TEXT;
|
||||
ALTER TABLE "Events" ADD COLUMN "VmName" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Events" DROP COLUMN "VmName";
|
||||
ALTER TABLE "Events" DROP COLUMN "ComputeResourceId";
|
||||
ALTER TABLE "Events" DROP COLUMN "DatacenterId";
|
||||
ALTER TABLE "Events" RENAME COLUMN "ComputeResourceName" TO "ComputeResource";
|
||||
ALTER TABLE "Events" RENAME COLUMN "DatacenterName" TO "Datacenter";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20240915015710_events_type.sql
Normal file
9
db/migrations_postgres/20240915015710_events_type.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Events" ADD COLUMN "EventType" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "EventType";
|
||||
-- +goose StatementEnd
|
||||
11
db/migrations_postgres/20240915232747_extend_inventory.sql
Normal file
11
db/migrations_postgres/20240915232747_extend_inventory.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" ADD COLUMN "IsTemplate" INTEGER;
|
||||
ALTER TABLE "Inventory" ADD COLUMN "PowerState" INTEGER;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" DROP COLUMN "PowerState";
|
||||
ALTER TABLE "Inventory" DROP COLUMN "IsTemplate";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20240916041639_rename_eventid.sql
Normal file
9
db/migrations_postgres/20240916041639_rename_eventid.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "EventId" TO "CloudId";
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "CloudId" TO "EventId";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20240916045259_updates_disk.sql
Normal file
9
db/migrations_postgres/20240916045259_updates_disk.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "NewProvisionedDisk" REAL;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "NewProvisionedDisk";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20240926022714_updates_user.sql
Normal file
9
db/migrations_postgres/20240926022714_updates_user.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "UserName" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "UserName";
|
||||
-- +goose StatementEnd
|
||||
55
db/migrations_postgres/20240927002029_change_inventory.sql
Normal file
55
db/migrations_postgres/20240927002029_change_inventory.sql
Normal file
@@ -0,0 +1,55 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "IsTemplate" TO "IsTemplate_old";
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "PowerState" TO "PowerState_old";
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "SrmPlaceholder" TO "SrmPlaceholder_old";
|
||||
ALTER TABLE "Inventory" ADD COLUMN "IsTemplate" TEXT NOT NULL DEFAULT 'FALSE';
|
||||
ALTER TABLE "Inventory" ADD COLUMN "PoweredOn" TEXT NOT NULL DEFAULT 'FALSE';
|
||||
ALTER TABLE "Inventory" ADD COLUMN "SrmPlaceholder" TEXT NOT NULL DEFAULT 'FALSE';
|
||||
UPDATE "Inventory"
|
||||
SET "IsTemplate" = CASE
|
||||
WHEN "IsTemplate_old" = 1 THEN 'TRUE'
|
||||
ELSE 'FALSE'
|
||||
END;
|
||||
UPDATE "Inventory"
|
||||
SET "PoweredOn" = CASE
|
||||
WHEN "PowerState_old" = 1 THEN 'TRUE'
|
||||
ELSE 'FALSE'
|
||||
END;
|
||||
UPDATE "Inventory"
|
||||
SET "SrmPlaceholder" = CASE
|
||||
WHEN "SrmPlaceholder_old" = 1 THEN 'TRUE'
|
||||
ELSE 'FALSE'
|
||||
END;
|
||||
ALTER TABLE "Inventory" DROP COLUMN "IsTemplate_old";
|
||||
ALTER TABLE "Inventory" DROP COLUMN "PowerState_old";
|
||||
ALTER TABLE "Inventory" DROP COLUMN "SrmPlaceholder_old";
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "IsTemplate" TO "IsTemplate_old";
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "PoweredOn" TO "PoweredOn_old";
|
||||
ALTER TABLE "Inventory" RENAME COLUMN "SrmPlaceholder" TO "SrmPlaceholder_old";
|
||||
ALTER TABLE "Inventory" ADD COLUMN "IsTemplate" INTEGER;
|
||||
ALTER TABLE "Inventory" ADD COLUMN "PowerState" INTEGER;
|
||||
ALTER TABLE "Inventory" ADD COLUMN "SrmPlaceholder" INTEGER;
|
||||
UPDATE "Inventory"
|
||||
SET "IsTemplate" = CASE
|
||||
WHEN "IsTemplate_old" = 'TRUE' THEN 1
|
||||
ELSE 0
|
||||
END;
|
||||
UPDATE "Inventory"
|
||||
SET "PowerState" = CASE
|
||||
WHEN "PoweredOn_old" = 'TRUE' THEN 1
|
||||
ELSE 0
|
||||
END;
|
||||
UPDATE "Inventory"
|
||||
SET "SrmPlaceholder" = CASE
|
||||
WHEN "SrmPlaceholder_old" = 'TRUE' THEN 1
|
||||
ELSE 0
|
||||
END;
|
||||
ALTER TABLE "Inventory" DROP COLUMN "IsTemplate_old";
|
||||
ALTER TABLE "Inventory" DROP COLUMN "PoweredOn_old";
|
||||
ALTER TABLE "Inventory" DROP COLUMN "SrmPlaceholder_old";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20240930012450_add_uuid.sql
Normal file
9
db/migrations_postgres/20240930012450_add_uuid.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" ADD COLUMN "VmUuid" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Inventory" DROP COLUMN "VmUuid";
|
||||
-- +goose StatementEnd
|
||||
18
db/migrations_postgres/20240930031506_add_table.sql
Normal file
18
db/migrations_postgres/20240930031506_add_table.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE IF NOT EXISTS "InventoryHistory" (
|
||||
"Hid" BIGSERIAL PRIMARY KEY,
|
||||
"InventoryId" INTEGER,
|
||||
"ReportDate" BIGINT,
|
||||
"UpdateTime" BIGINT,
|
||||
"PreviousVcpus" INTEGER,
|
||||
"PreviousRam" INTEGER,
|
||||
"PreviousResourcePool" TEXT,
|
||||
"PreviousProvisionedDisk" REAL
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE "InventoryHistory";
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "PlaceholderChange" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "PlaceholderChange";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20241002032439_add_name.sql
Normal file
9
db/migrations_postgres/20241002032439_add_name.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "Name" TEXT;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "Name";
|
||||
-- +goose StatementEnd
|
||||
9
db/migrations_postgres/20241002033323_add_change.sql
Normal file
9
db/migrations_postgres/20241002033323_add_change.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" ADD COLUMN "RawChangeString" BYTEA;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE "Updates" DROP COLUMN "RawChangeString";
|
||||
-- +goose StatementEnd
|
||||
Reference in New Issue
Block a user