1 CREATE TABLE "folder" (
\r
2 [folder_id] INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1),
\r
4 [path] NVARCHAR(266) UNIQUE NOT NULL,
\r
5 [indexed_on] DATETIME DEFAULT GETDATE() NOT NULL,
\r
7 CONSTRAINT FK_FOLDER_PARENT_FOLDER_ID_TO_FOLDER_FOLDER_ID
\r
8 FOREIGN KEY (parent_id) REFERENCES folder(folder_id) ON DELETE NO ACTION,
\r
10 CONSTRAINT IDX_FOLDER_PATH
\r
14 CREATE TABLE "file" (
\r
15 [file_id] INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1),
\r
16 [parent_folder_id] INTEGER NOT NULL,
\r
17 [name] NVARCHAR(255),
\r
18 [type] VARCHAR(250),
\r
19 [size] BIGINT NOT NULL,
\r
20 [indexed_on] DATETIME DEFAULT GETDATE() NOT NULL,
\r
22 CONSTRAINT FK_FILE_PARENT_FOLDER_ID_TO_FOLDER_FOLDER_ID
\r
23 FOREIGN KEY (parent_folder_id) REFERENCES folder(folder_id) ON DELETE CASCADE,
\r
25 CONSTRAINT IDX_NAME_PARENT_FOLDER_ID
\r
26 UNIQUE (parent_folder_id, name)
\r
29 SET IDENTITY_INSERT FOLDER ON;
\r
31 INSERT INTO folder (folder_id, parent_id, path)
\r
32 VALUES (1, null, 'root');