text: SET NOCOUNT ON
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Users')
  BEGIN
  	PRINT 'Creating Users table'
  	CREATE TABLE [dbo].[Users] (
  		Id BIGINT CONSTRAINT PK_Users_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		Name NVARCHAR(50) NOT NULL,
  		Email VARCHAR(50) NOT NULL CONSTRAINT UQ_Users_Email UNIQUE (Email),
  		Password VARCHAR(100) NOT NULL,
  		CreatedAt DATETIME NOT NULL,
  		EmailConfirmedAt DATETIME NULL,
  		DeletedAt DATETIME NULL
  	)
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'DocumentClaims')
  BEGIN
  	PRINT 'Creating DocumentClaims table'
  	CREATE TABLE [dbo].[DocumentClaims] (
  		Id BIGINT CONSTRAINT PK_DocumentClaims_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		UserId BIGINT NOT NULL,
  		AvailableFree INT NOT NULL,
  		RemainingQuota INT NOT NULL,
  		Reason VARCHAR(100) NOT NULL,
  		CONSTRAINT FK_DocumentClaims_UserId FOREIGN KEY(UserId) REFERENCES Users(Id)
  	)
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Referrals')
  BEGIN
  	PRINT 'Creating Referrals table'
  	CREATE TABLE [dbo].[Referrals] (
  		Id BIGINT CONSTRAINT PK_Referrals_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		UserId BIGINT NOT NULL,
  		PromoCode VARCHAR(10) NOT NULL CONSTRAINT UQ_Referrals_PromoCode UNIQUE (PromoCode),
  		InvitedEmail VARCHAR(50) NOT NULL,
  		InvitedUserId BIGINT NULL,
  		CONSTRAINT FK_Referrals_UserId FOREIGN KEY(UserId) REFERENCES Users(Id),
  		CONSTRAINT FK_Referrals_InvitedUserId FOREIGN KEY(InvitedUserId) REFERENCES Users(Id)
  	)
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Universities')
  BEGIN
  	PRINT 'Creating Universities table'
  	CREATE TABLE [dbo].[Universities] (
  		Id BIGINT CONSTRAINT PK_Universities_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		Name NVARCHAR(150) NOT NULL CONSTRAINT UQ_Universities_Name UNIQUE (Name)
  	)
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Documents')
  BEGIN
  	PRINT 'Creating Documents table'
  	CREATE TABLE [dbo].[Documents](
  		Id BIGINT CONSTRAINT PK_Documents_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		FullDocumentFileName VARCHAR(50) NOT NULL CONSTRAINT UQ_Documents_FullDocumentFileName UNIQUE (FullDocumentFileName),
  		FreeSnippetFileName VARCHAR(50) NOT NULL CONSTRAINT UQ_Documents_FreeSnippetFileName UNIQUE (FreeSnippetFileName),
  		OriginalFileName NVARCHAR(150) NOT NULL,
  		Title NVARCHAR(500) NOT NULL,
  		Description NVARCHAR(4000) NOT NULL,
  		Degree VARCHAR(100) NOT NULL,
  		CourseName VARCHAR(100) NULL,
  		CourseCode VARCHAR(100) NULL,
  		Year VARCHAR(20) NOT NULL,
  		UniversityId BIGINT NOT NULL,
  		UploadedBy BIGINT NOT NULL,
  		UploadedAt DATETIME NOT NULL,
  		DeletedAt DATETIME NULL,
  		CONSTRAINT FK_Documents_UniversityId FOREIGN KEY(UniversityId) REFERENCES Universities(Id),
  		CONSTRAINT FK_Documents_UploadedBy FOREIGN KEY(UploadedBy) REFERENCES Users(Id),
  	)
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Purchases')
  BEGIN
  	PRINT 'Creating Purchases table'
  	CREATE TABLE [dbo].[Purchases](
  		Id BIGINT CONSTRAINT PK_Purchases_Id PRIMARY KEY IDENTITY(1,1) NOT NULL,
  		DocumentId BIGINT NOT NULL,
  		BuyerId BIGINT NOT NULL,
  		PurchasedAt DATETIME NOT NULL,
  		TransactionId VARCHAR(100) NOT NULL,
  		CONSTRAINT FK_Purchases_DocumentId FOREIGN KEY(DocumentId) REFERENCES Documents(Id),
  		CONSTRAINT FK_Purchases_BuyerId FOREIGN KEY(BuyerId) REFERENCES Users(Id),
  	)
  END
  GO
  
  SET NOCOUNT OFF