- Replaced references to `api.settings` with `api.etichette`, `api.flags`, and `api.strings` in various admin pages to align with new API structure. - Removed the deprecated `settingsRouter` and introduced `flagsRouter`, `etichetteRouter`, and `stringsRouter` to handle respective functionalities. - Updated the `Flags` schema to change the `value` field from string to boolean. - Modified flag handling logic in the `SendMessage` and `NewMail` functions to check for boolean flags instead of string values. - Added migration script to convert the `value` column in the `flags` table from string to boolean. - Implemented new routers for banners, etichette, flags, revalidation, and strings to encapsulate related functionalities.
25 lines
No EOL
834 B
SQL
25 lines
No EOL
834 B
SQL
-- Converts the 'value' column from a string to a boolean.
|
|
-- If 'value' is 'true' (case insensitive), it will be set to TRUE, otherwise FALSE.
|
|
|
|
DO $$
|
|
BEGIN
|
|
-- Check if the column is not already boolean
|
|
IF EXISTS (
|
|
SELECT 1
|
|
FROM information_schema.columns
|
|
WHERE table_schema = 'public'
|
|
AND table_name = 'flags'
|
|
AND column_name = 'value'
|
|
AND data_type != 'boolean'
|
|
) THEN
|
|
-- Convert the column type
|
|
ALTER TABLE public.flags
|
|
ALTER COLUMN value TYPE BOOLEAN USING (LOWER(value) = 'true');
|
|
END IF;
|
|
END $$;
|
|
|
|
-- Ensure that the 'value' column is not NULL (idempotent)
|
|
ALTER TABLE public.flags ALTER COLUMN VALUE SET NOT NULL;
|
|
|
|
-- Set a default value for the 'value' column (idempotent)
|
|
ALTER TABLE public.flags ALTER COLUMN VALUE SET DEFAULT FALSE; |