Skip to content

Commit e1fa716

Browse files
Metadata (#351)
* Made a Metadata schema, currently just has a foreign key to the filesystem table. * Changed it so that file system also reference metadata. * changed the field name, and remove the foreign key from meta table to filesystem. * fixed pipeline failure * fixed pipeline failure * fixed pipeline failure * removed fk constraint - easier migration * removed fk constraint - easier migration --------- Co-authored-by: Varun Sethu <[email protected]>
1 parent c7c72b7 commit e1fa716

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

postgres/dbver.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
2

postgres/up/05-create_filesystem_table.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
SET timezone = 'Australia/Sydney';
22
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
33

4+
/* MetaData */
5+
DROP TABLE IF EXISTS metadata;
6+
CREATE TABLE metadata (
7+
MetadataID uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
8+
CreatedAt TIMESTAMP NOT NULL DEFAULT NOW()
9+
);
10+
411
/**
512
The filesystem table models all file heirachies in our system
613
**/
@@ -13,13 +20,19 @@ CREATE TABLE filesystem (
1320
IsPublished BOOLEAN DEFAULT false,
1421
CreatedAt TIMESTAMP NOT NULL DEFAULT NOW(),
1522

23+
/* MetaData */
24+
-- MetadataID uuid NOT NULL,
25+
1626
OwnedBy INT,
1727
/* Pain */
1828
Parent uuid REFERENCES filesystem(EntityID) DEFAULT NULL,
1929

2030
/* FK Constraint */
2131
CONSTRAINT fk_owner FOREIGN KEY (OwnedBy)
2232
REFERENCES groups(UID),
33+
34+
-- CONSTRAINT fk_meta FOREIGN KEY (MetadataID) REFERENCES metadata(MetadataID),
35+
2336
/* Unique name constraint: there should not exist an entity of the same type with the
2437
same parent and logical name. */
2538
CONSTRAINT unique_name UNIQUE (Parent, LogicalName, IsDocument)
@@ -70,4 +83,4 @@ BEGIN
7083
END IF;
7184

7285
DELETE FROM filesystem WHERE EntityID = entityIDP;
73-
END $$;
86+
END $$;

0 commit comments

Comments
 (0)