I have table with Tenants
Model for this table is
create table dbo.AbpTenants
(
Id int identity
constraint PK_AbpTenants
primary key,
ConnectionString nvarchar(1024),
CreationTime datetime2 not null,
CreatorUserId bigint
constraint FK_AbpTenants_AbpUsers_CreatorUserId
references dbo.AbpUsers,
CustomCssId uniqueidentifier,
DeleterUserId bigint
constraint FK_AbpTenants_AbpUsers_DeleterUserId
references dbo.AbpUsers,
DeletionTime datetime2,
EditionId int
constraint FK_AbpTenants_AbpEditions_EditionId
references dbo.AbpEditions,
IsActive bit not null,
IsDeleted bit not null,
LastModificationTime datetime2,
LastModifierUserId bigint
constraint FK_AbpTenants_AbpUsers_LastModifierUserId
references dbo.AbpUsers,
LogoFileType nvarchar(64),
LogoId uniqueidentifier,
Name nvarchar(128) not null,
TenancyName nvarchar(64) not null,
IsInTrialPeriod bit default CONVERT([bit], 0) not null,
SubscriptionEndDateUtc datetime2,
ReportsLogoFileType nvarchar(64),
ReportsLogoId uniqueidentifier,
SubscriptionPaymentType int default 0 not null
)
go
Also I have PricingTier table
create table dbo.PricingTier
(
Id int identity
constraint PK_PricingTier
primary key,
TenantId int not null,
Name nvarchar(50),
CreationTime datetime2 not null,
CreatorUserId bigint,
LastModificationTime datetime2,
LastModifierUserId bigint,
IsDeleted bit not null,
DeleterUserId bigint,
DeletionTime datetime2,
IsDefault bit default CONVERT([bit], 0) not null
)
go
Pricing tier doesn’t has FK to tenant, this is okay.
I need to write SQL script to create PricingTier for every Tenant that doesn’t have pricing tiers with name Retail
and IsDefault = true
How I can do this?