Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion postgres/dbver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
2
15 changes: 14 additions & 1 deletion postgres/up/05-create_filesystem_table.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
SET timezone = 'Australia/Sydney';
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

/* MetaData */
DROP TABLE IF EXISTS metadata;
CREATE TABLE metadata (
MetadataID uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
CreatedAt TIMESTAMP NOT NULL DEFAULT NOW()
);

/**
The filesystem table models all file heirachies in our system
**/
Expand All @@ -13,13 +20,19 @@ CREATE TABLE filesystem (
IsPublished BOOLEAN DEFAULT false,
CreatedAt TIMESTAMP NOT NULL DEFAULT NOW(),

/* MetaData */
-- MetadataID uuid NOT NULL,

OwnedBy INT,
/* Pain */
Parent uuid REFERENCES filesystem(EntityID) DEFAULT NULL,

/* FK Constraint */
CONSTRAINT fk_owner FOREIGN KEY (OwnedBy)
REFERENCES groups(UID),

-- CONSTRAINT fk_meta FOREIGN KEY (MetadataID) REFERENCES metadata(MetadataID),

/* Unique name constraint: there should not exist an entity of the same type with the
same parent and logical name. */
CONSTRAINT unique_name UNIQUE (Parent, LogicalName, IsDocument)
Expand Down Expand Up @@ -70,4 +83,4 @@ BEGIN
END IF;

DELETE FROM filesystem WHERE EntityID = entityIDP;
END $$;
END $$;