fix: preserve nested hard-break content and use timestamptz

remarkSplitBlocks was splicing after-break paragraphs onto the root
tree, which dropped content inside list items and other nested parents.
Insert the split sibling into the actual parent instead.

Also store timestamps as timestamptz so Drizzle no longer treats naive
timestamp values as UTC and shifts displayed times by the server offset.
This commit is contained in:
Zoe
2026-07-19 14:03:14 -05:00
parent 28ef0c8a07
commit 166052012d
4 changed files with 2864 additions and 45 deletions
@@ -0,0 +1,58 @@
-- Convert naive timestamps to timestamptz.
-- Existing values were written as session-local wall clocks (via now()/defaultNow)
-- or occasionally as UTC components (drizzle mapToDriverValue toISOString).
-- Interpret stored values in the current session TimeZone so local wall-clock
-- rows (the common path for messages) keep the same absolute instant.
--
-- Drizzle reads naive `timestamp` as UTC (textToDateWithTz), which shifted
-- displayed times by the server offset (e.g. -5h in America/Chicago).
ALTER TABLE "providers"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "models"
ALTER COLUMN "released_at" TYPE timestamptz USING "released_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "agents"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "topics"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "messages"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "message_parts"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "last_updated_at" TYPE timestamptz USING "last_updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "tool_calls"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "files"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "attachments"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "users"
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "sessions"
ALTER COLUMN "expires_at" TYPE timestamptz USING "expires_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "accounts"
ALTER COLUMN "access_token_expires_at" TYPE timestamptz USING "access_token_expires_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "refresh_token_expires_at" TYPE timestamptz USING "refresh_token_expires_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');
ALTER TABLE "verifications"
ALTER COLUMN "expires_at" TYPE timestamptz USING "expires_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "created_at" TYPE timestamptz USING "created_at" AT TIME ZONE current_setting('TimeZone'),
ALTER COLUMN "updated_at" TYPE timestamptz USING "updated_at" AT TIME ZONE current_setting('TimeZone');