| | 1 | == Writer Adds a Chapter to a Story |
| | 2 | |
| | 3 | === Authors: **Writter** |
| | 4 | A writer adds a new chapter to an existing published or draft story, providing chapter details such as title, content, and chapter number. |
| | 5 | |
| | 6 | **1.** The writer navigates to their story and selects "Add New Chapter". |
| | 7 | |
| | 8 | **2.** The system displays the chapter creation form requesting chapter number, chapter name, title, and content. |
| | 9 | |
| | 10 | **3.** The system checks what chapter number should come next. |
| | 11 | |
| | 12 | {{{#!sql |
| | 13 | SELECT MAX(chapter_number) + 1 AS next_chapter |
| | 14 | FROM CHAPTER |
| | 15 | WHERE story_id = 1; |
| | 16 | }}} |
| | 17 | **4.** The writer fills in all chapter details and submits the form. |
| | 18 | |
| | 19 | **5.** The system inserts a new record into the CHAPTER table. |
| | 20 | |
| | 21 | {{{#!sql |
| | 22 | INSERT INTO CHAPTER (chapter_number, chapter_name, title, content, word_count, published_at, view_count, story_id, created_at, updated_at) |
| | 23 | VALUES (4, 'Chapter Four', 'The Council of Kings', |
| | 24 | 'Lyra stood before the five thrones, her heart hammering...', |
| | 25 | 3800, CURRENT_TIMESTAMP, 0, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); |
| | 26 | }}} |
| | 27 | |
| | 28 | **6.** The system notifies all users who have the story in their reading list. |
| | 29 | {{{#!sql |
| | 30 | INSERT INTO NOTIFICATION (content, is_read, created_at) |
| | 31 | VALUES ('Elena published a new chapter of "The Chronicles of Eldoria"', FALSE, CURRENT_TIMESTAMP); |
| | 32 | }}} |
| | 33 | |
| | 34 | **7.** The system confirms the chapter was added and displays it on the story page. |