mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
31 lines
757 B
SQL
31 lines
757 B
SQL
CREATE TABLE BreweryPost -- A user cannot be deleted if they have a post
|
|
(
|
|
BreweryPostID UNIQUEIDENTIFIER
|
|
CONSTRAINT DF_BreweryPostID DEFAULT NEWID(),
|
|
|
|
BreweryName NVARCHAR(256) NOT NULL,
|
|
|
|
PostedByID UNIQUEIDENTIFIER NOT NULL,
|
|
|
|
Description NVARCHAR(MAX) NOT NULL,
|
|
|
|
CreatedAt DATETIME NOT NULL
|
|
CONSTRAINT DF_BreweryPost_CreatedAt DEFAULT GETDATE(),
|
|
|
|
UpdatedAt DATETIME NULL,
|
|
|
|
RowVersion ROWVERSION,
|
|
|
|
CONSTRAINT PK_BreweryPost
|
|
PRIMARY KEY (BreweryPostID),
|
|
|
|
CONSTRAINT FK_BreweryPost_UserAccount
|
|
FOREIGN KEY (PostedByID)
|
|
REFERENCES UserAccount (UserAccountID)
|
|
ON DELETE NO ACTION
|
|
);
|
|
|
|
CREATE
|
|
NONCLUSTERED INDEX IX_BreweryPost_PostedByID
|
|
ON BreweryPost(PostedByID);
|