Created
March 18, 2015 20:25
-
-
Save FaronBracy/a2aabd485725165c677a to your computer and use it in GitHub Desktop.
Create a project version table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create new table for keeping track of all the versions of project files | |
CREATE TABLE wa.ProjectVersion( | |
ProjectVersionId int IDENTITY(1,1) NOT NULL, | |
ProjectId int NOT NULL, | |
DateCreated datetime2(7) NOT NULL, | |
ProjectFileId varchar(50) NOT NULL | |
PRIMARY KEY CLUSTERED | |
( | |
ProjectVersionId ASC | |
) | |
) | |
-- Create a FK on ProjectId from ProjectVersion to the Project | |
ALTER TABLE wa.ProjectVersion | |
WITH CHECK ADD CONSTRAINT FK_ProjectVersion_Project_ProjectId FOREIGN KEY(ProjectId) | |
REFERENCES wa.Project(ProjectId) | |
-- Create a FK on LatestProjectVersionId from Project to the ProjectVersion | |
ALTER TABLE wa.Project | |
ADD LatestProjectVersionId int NOT NULL | |
ALTER TABLE wa.Project | |
WITH CHECK ADD CONSTRAINT FK_Project_LatestProjectVersionId_ProjectVersion_ProjectVersionId FOREIGN KEY(LatestProjectVersionId) | |
REFERENCES wa.ProjectVersion (ProjectVersionId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment