diff --git a/iac/AzureSQLServer-Seed.sql b/iac/AzureSQLServer-Seed.sql index b8cc73a4..fb5bc4c2 100644 --- a/iac/AzureSQLServer-Seed.sql +++ b/iac/AzureSQLServer-Seed.sql @@ -1,4 +1,12 @@ -- noinspection SqlDialectInspectionForFile +-- Note: We are deliberately defining most columns (in most of the read-model tables) as "string nvarchar(max)", and only specifically using other datatypes, where we know they are very un-likely to change over time. +-- We are deliberately defining most columns as NULL for the same reason. To avoid, as much as possible, having to make changes to the schema in the future, when the code changes. +-- Most read-model columns will change from string to JSON(ValueObject) as things change in your domain models, so limiting them too early to specific datatypes can backfire later on in production workloads. +-- If you want to be more specific and want to optimize column design early, you need to be very careful not to change the code in the future. +-- We recommend optimizing for change, rather than for performance, until your product has matured and fully developed, or has scaled dramatically. +-- Clearly there are limits to this, so this strategy is simply minimizing them, since we don't care at this stage about optimizing SQL storage in the cloud (i.e. no longer depend on spinning hard disks, tracks and sectors). +-- "nvarchar(max)" is used as a default for all string fields to allow for future expansion of the data model without having to change the schema. You are free to modify that limit (across the board) at your will. +-- Some columns with indexes cannot be nvarchar(max) because of the index size limit of 900 bytes. USE [SaaStack] @@ -204,14 +212,14 @@ CREATE INDEX UserId CREATE TABLE [dbo].[AuthToken] ( - [Id] [nvarchar](100) NOT NULL, - [LastPersistedAtUtc] [datetime] NULL, - [IsDeleted] [bit] NULL, - [AccessToken] [nvarchar](450) NULL, - [AccessTokenExpiresOn] [datetime] NULL, - [RefreshToken] [nvarchar](450) NULL, - [RefreshTokenExpiresOn] [datetime] NULL, - [UserId] [nvarchar](100) NULL, + [Id] [nvarchar](100) NOT NULL, + [LastPersistedAtUtc] [datetime] NULL, + [IsDeleted] [bit] NULL, + [AccessToken] [nvarchar](4000) NULL, + [AccessTokenExpiresOn] [datetime] NULL, + [RefreshToken] [nvarchar](4000) NULL, + [RefreshTokenExpiresOn] [datetime] NULL, + [UserId] [nvarchar](100) NULL, ) ON [PRIMARY] GO @@ -220,11 +228,6 @@ CREATE INDEX Id ( [Id] ); -CREATE INDEX RefreshToken - ON [dbo].[AuthToken] - ( - [RefreshToken] - ); CREATE INDEX UserId ON [dbo].[AuthToken] ( diff --git a/src/.idea/.idea.SaaStack/.idea/codeStyles/Project.xml b/src/.idea/.idea.SaaStack/.idea/codeStyles/Project.xml index 6364ff59..f324aeb3 100644 --- a/src/.idea/.idea.SaaStack/.idea/codeStyles/Project.xml +++ b/src/.idea/.idea.SaaStack/.idea/codeStyles/Project.xml @@ -1,5 +1,8 @@ + +