diff --git a/dal/schema/000030_init.down.sql b/dal/schema/000030_init.down.sql new file mode 100644 index 0000000..e0a6cc4 --- /dev/null +++ b/dal/schema/000030_init.down.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS YclientsTokens ( + AccountID VARCHAR(30) PRIMARY KEY, + SalonID int not null, -- ID компании + AccessToken TEXT NOT NULL DEFAULT '', + Active BOOLEAN NOT NULL DEFAULT FALSE, + Expiration BOOLEAN NOT NULL DEFAULT FALSE, -- флаг истек ли токен + CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + +create UNIQUE INDEX idx_unique_tokens_yclients ON YclientsTokens (SalonID, AccountID) WHERE Active = true and Expiration = false; + +ALTER TABLE YclientsAccounts + ADD COLUMN IF NOT EXISTS ShortDecription text NOT NULL DEFAULT '', + ADD COLUMN IF NOT EXISTS Country VARCHAR(50) NOT NULL DEFAULT ''; + +ALTER TABLE YclientsTimeSlots + ALTER COLUMN DatesSettings SET DEFAULT '{}'::jsonb; + +UPDATE YclientsTimeSlots +SET DatesSettings = '{}'::jsonb +WHERE DatesSettings = '[]'::jsonb; + +ALTER TABLE YclientsServices +ALTER COLUMN PriceMin TYPE TEXT, +ALTER COLUMN PriceMax TYPE TEXT, +ALTER COLUMN Discount TYPE TEXT; \ No newline at end of file diff --git a/dal/schema/000030_init.up.sql b/dal/schema/000030_init.up.sql new file mode 100644 index 0000000..f87c5df --- /dev/null +++ b/dal/schema/000030_init.up.sql @@ -0,0 +1,18 @@ +DROP INDEX if EXISTS idx_unique_tokens_yclients; +DROP TABLE IF EXISTS YclientsTokens; + +ALTER TABLE YclientsAccounts +DROP COLUMN IF EXISTS ShortDecription, +DROP COLUMN IF EXISTS Country; + +ALTER TABLE YclientsTimeSlots + ALTER COLUMN DatesSettings SET DEFAULT '[]'::jsonb; + +UPDATE YclientsTimeSlots +SET DatesSettings = '[]'::jsonb +WHERE DatesSettings = '{}'::jsonb; + +ALTER TABLE YclientsServices +ALTER COLUMN PriceMin TYPE FLOAT USING NULLIF(PriceMin, '')::FLOAT, +ALTER COLUMN PriceMax TYPE FLOAT USING NULLIF(PriceMax, '')::FLOAT, +ALTER COLUMN Discount TYPE INT USING NULLIF(Discount, '')::INT; \ No newline at end of file