-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from codex-team/fix-500-web
Fix 500 in editor-tools in API
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- This migration script alters the data type of the id column to SERIAL | ||
-- Make sure to run this after the initial migration where the table was created | ||
|
||
-- Rename the table to avoid conflicts temporarily | ||
ALTER TABLE public.editor_tools RENAME TO temp_editor_tools; | ||
|
||
-- Create a new table with the same structure but with id column as SERIAL | ||
CREATE TABLE public.editor_tools ( | ||
id SERIAL PRIMARY KEY, | ||
name character varying(255) NOT NULL, | ||
export_name character varying(255) NOT NULL, | ||
source json NOT NULL, | ||
is_default BOOLEAN DEFAULT false | ||
); | ||
|
||
-- Copy data from the temporary table to the new table | ||
INSERT INTO public.editor_tools (name, export_name, source, is_default) | ||
SELECT name, export_name, source, is_default FROM temp_editor_tools; | ||
|
||
-- Drop the temporary table | ||
DROP TABLE temp_editor_tools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Add column "title" to "editor_tools" if it doesn't exist | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS(SELECT * | ||
FROM information_schema.columns | ||
WHERE table_name='editor_tools' AND column_name='title') | ||
THEN | ||
ALTER TABLE "public"."editor_tools" ADD COLUMN "title" VARCHAR(255); -- Adjust the data type and size as needed | ||
END IF; | ||
END $$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DO $$ | ||
BEGIN | ||
-- Add data for Header tool | ||
IF NOT EXISTS(SELECT * FROM public.editor_tools WHERE name = 'header') | ||
THEN | ||
INSERT INTO public.editor_tools (name, title, export_name, source, is_default) | ||
VALUES ('header', 'Heading', 'Header', '{"cdn": "https://cdn.jsdelivr.net/npm/@editorjs/header@2.8.1/dist/header.umd.min.js"}'::json, true); | ||
END IF; | ||
|
||
-- Add data for Paragraph tool | ||
IF NOT EXISTS(SELECT * FROM public.editor_tools WHERE name = 'paragraph') | ||
THEN | ||
INSERT INTO public.editor_tools (name, title, export_name, source, is_default) | ||
VALUES ('paragraph', 'Paragraph', 'Paragraph', '{"cdn": "https://cdn.jsdelivr.net/npm/@editorjs/paragraph@2.11.3/dist/paragraph.umd.min.js"}'::json, true); | ||
END IF; | ||
|
||
-- Add data for List tool | ||
IF NOT EXISTS(SELECT * FROM public.editor_tools WHERE name = 'list') | ||
THEN | ||
INSERT INTO public.editor_tools (name, title, export_name, source, is_default) | ||
VALUES ('list', 'List', 'List', '{"cdn": "https://cdn.jsdelivr.net/npm/@editorjs/list@1.9.0/dist/list.umd.min.js"}'::json, true); | ||
END IF; | ||
END $$; |