CREATE TABLE uploaded_files (
    uploaded_file_id int NOT NULL ,
	resource_id int NOT NULL ,
	parent_uploaded_file_id int,
	create_user_id int NOT NULL ,
	update_user_id int NOT NULL ,
	created_time TIMESTAMP NOT NULL ,
	updated_time TIMESTAMP NOT NULL ,
	flags int NOT NULL ,
	low_size int NOT NULL ,
	high_size int NOT NULL ,
	low_bytes_uploaded int NOT NULL ,
	high_bytes_uploaded int NOT NULL ,
	name VARCHAR(255) ,
	url VARCHAR(255) ,
	mime_type VARCHAR(63) NOT NULL ,
	left_index int NOT NULL ,
	right_index int NOT NULL ,
	CONSTRAINT PK_uploaded_files PRIMARY KEY
	(
		uploaded_file_id
	),
	CONSTRAINT FK_uploaded_files_to_resources FOREIGN KEY
	(
		resource_id
	) REFERENCES resources (
		resource_id
	),
	CONSTRAINT FK_uploaded_files_to_users_1 FOREIGN KEY
	(
		create_user_id
	) REFERENCES users (
		user_id
	),
	CONSTRAINT FK_uploaded_files_to_users_2 FOREIGN KEY
	(
		update_user_id
	) REFERENCES users (
		user_id
	)	
	)
GO


INSERT INTO classes (type, super_type, db_name, table_name, java_class)
	VALUES(27, NULL, 'building2', 'uploaded_files', 'org.bodington.server.resources.UploadedFile')
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 1, 'uploaded_file_id', 'setUploadedFileId', 'getUploadedFileId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 1, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 2, 'resource_id', 'setResourceId', 'getResourceId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 3, 'parent_uploaded_file_id', 'setParentUploadedFileId', 'getParentUploadedFileId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 4, 'create_user_id', 'setCreateUserId', 'getCreateUserId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 5, 'update_user_id', 'setUpdateUserId', 'getUpdateUserId', 'org.bodington.database.PrimaryKey', 'org.bodington.database.PrimaryKey', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 6, 'created_time', 'setCreatedTime', 'getCreatedTime', 'java.sql.Timestamp', 'java.sql.Timestamp', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 7, 'updated_time', 'setUpdatedTime', 'getUpdatedTime', 'java.sql.Timestamp', 'java.sql.Timestamp', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 8, 'flags', 'setFlags', 'getFlags', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 9, 'low_size', 'setLowSize', 'getLowSize', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 10, 'high_size', 'setHighSize', 'getHighSize', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 11, 'low_bytes_uploaded', 'setLowBytesUploaded', 'getLowBytesUploaded', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 12, 'high_bytes_uploaded', 'setHighBytesUploaded', 'getHighBytesUploaded', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 13, 'name', 'setName', 'getName', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 14, 'url', 'setUrl', 'getUrl', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 15, 'mime_type', 'setMimeType', 'getMimeType', 'java.lang.String', 'java.lang.String', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 16, 'left_index', 'setLeftIndex', 'getLeftIndex', 'int', 'int', 0, null, null, null )
GO

INSERT INTO fields (type, sequence, field, set_method_name, get_method_name, set_java_class, get_java_class, flags, foreign_type, set_method_name_foreign, get_method_name_foreign )
	VALUES(27, 17, 'right_index', 'setRightIndex', 'getRightIndex', 'int', 'int', 0, null, null, null )
GO

