Skip to content

Posts 0.5.0: Long subtitles and slugs no longer crash the post editor

Posts 0.5.0 stops the post editor failing with a server error when a subtitle, repost link or slug is too long for the database, makes inserting pictures work after moving between pages, and gives the module its own migration chain.

Too-long fields get a form error

Three fields were checked against limits that did not match their database columns, so a save passed the form’s checks and then failed with a server error instead of a message:

  • The subtitle was allowed 500 characters against a 255-character column. The editor’s own counter offered 500, taken from the subtitle length setting. The editor now caps the title and subtitle counters at what the columns hold, even if the setting is higher.
  • The repost link had no length limit at all. It now stops at 255 characters.
  • A second post with the same 255-character title got a slug two characters too long. The slug is now shortened to leave room for the number added to keep it unique.

Group and tag slugs typed by hand are also checked against their columns now.

Inserting pictures into a post

Inserting an image or a video into the post body only worked when the editor page was loaded fresh. Coming to the new post page or a post’s edit page from another admin page left it doing nothing. It now works either way.

The publish, move to draft, edit, delete and view buttons in the posts list are now translated into Estonian and Russian.

The module owns its tables

The module’s 13 tables now have their own migration chain. On existing sites the first step changes nothing in the tables: it only records that the module has taken them over. Rolling the chain back never drops a table or deletes posts; the README explains how to remove the tables by hand if you uninstall the module.

Upgrading

Update the dependency, then run mix phoenix_kit.update. It generates one migration for the Posts module, which marks the tables as the module’s own and changes nothing else. The PhoenixKit requirement stays at 2.16 or later.

Full release notes: Posts 0.5.0

0.5.0 · 16 September 2026

Changed

  • The 13 phoenix_kit_post*/phoenix_kit_comment_* tables’ future shape now belongs to a module-owned migration chain, PhoenixKitPosts.Migrations, marker pkpo_schema:<N> on phoenix_kit_posts, following the canonical dual-reader protocol documented by phoenix_kit_hello_world and used by phoenix_kit_dashboards/phoenix_kit_warehouse (migrated_version/1 for migration context, migrated_version_runtime/1 for mix phoenix_kit.update; up/1 re-reads the version before changing anything). Varchar widths are sourced from each owning schema’s column_widths/0 (Post, PostComment, PostGroup, PostMention, PostTag, PostView) — the single shape authority — never restated as a second number.

    Ownership unfolds in three phases:

    • Phase 0 (this release) — V1 is an adoption, not a create: core’s V135/V167/V168/V185 baseline still creates all 13 tables (and phoenix_kit_posts.time_zone) on every install, and V1 re-asserts that exact shape idempotently — every pkey, index, and the full 24-FK set (9 to phoenix_kit_users, 1 self-referential on phoenix_kit_post_comments, 1 to phoenix_kit_post_groups, 1 to phoenix_kit_post_tags, 2 to phoenix_kit_files, 8 to phoenix_kit_posts, 2 to phoenix_kit_post_comments) — and stamps the marker. Because no shape changes, core’s ExpectedSchema stays accurate — no core release is required and there is no release-ordering hazard.
    • Phase 1 (a future V2+) — the first real shape change requires first adding the altered objects to core’s manifest generator’s @excluded_exact and regenerating ExpectedSchema, then raising this package’s core floor to that release. Five unique constraints this module’s schemas already assert via unique_constraint/3 but core never backed with an index (post_likes/post_dislikes/ post_mentions on (post_uuid, user_uuid), comment_likes/ comment_dislikes on (comment_uuid, user_uuid)) are a documented gap left for that first real version, not fixed here.
    • Phase 2 (a future core baseline squash) — once core stops creating these tables for fresh installs, V1’s CREATE TABLE statements become the only thing that ever creates them from scratch, which is why up/1 already ensures uuid_generate_v7() (and its pgcrypto extension) exist rather than assuming core’s chain provided them.

    down/1 can never drop a table, for any target including 0. It unstamps (or re-stamps) the marker on phoenix_kit_posts and nothing else: the rows are every user’s posts, likes, tags, groups, media, mentions, views and legacy comments, and on most installs every table is core-created. Test-pinned — no statement in either direction may match DROP/TRUNCATE/DELETE. There is deliberately no automated uninstall path; README.md’s new “Removing this module” section gives the operator manual SQL instead.

    Existing hosts: upgrade, then mix phoenix_kit.update; it generates a posts_update_v00_to_v01.exs migration that stamps pkpo_schema:1 and nothing else changes. New hosts and hosts without this module: unchanged.

    This is the third of a planned series of similar module-owned-migration adoptions across phoenix_kit_* packages (after phoenix_kit_dashboards and phoenix_kit_warehouse) that today rely entirely on core’s versioned chain for their own tables.

Added

  • test/integration/migrations_shape_identity_test.exs — the chain checked against a real database instead of a description of one. Core’s whole chain builds into one schema, V1 builds from scratch into another holding only stub phoenix_kit_users / phoenix_kit_files tables, and every column, index and constraint of the 13 tables is diffed out of Postgres’ own catalogue. The existing manifest comparison is core describing itself; this is the arbiter disagreeing with both if they drift. It is also the only exercise of V1’s CREATE TABLE statements, which are no-ops on every install until core’s Phase 2 baseline squash makes them the only thing that builds these tables.
  • test/integration/column_width_test.exs — every writable character varying(n) column pinned to its schema’s column_widths/0.

Fixed

  • A subtitle, repost URL or generated slug wider than its column no longer 500s the editor. Three character varying columns were validated against numbers that disagreed with the database, so the changeset reported valid? and Postgres then raised 22001 string_data_right_truncation on the insert — an unhandled Postgrex.Error rather than a form error. Post.changeset/2 now drives every validate_length/3 from column_widths/0, the same map the migration chain builds its DDL from:

    • sub_title was checked against 500 against a varchar(255) column, and the editor’s own character counter and maxlength came from posts_max_subtitle_length, whose default is 500 — the page actively invited the input that broke it. Web.Edit now clamps both the title and subtitle limits to the real column widths, so a setting above the column is absorbed rather than advertised.
    • repost_url had no length bound at all, against a varchar(255) column. A repost URL with a long query string is ordinary.
    • A second post sharing a 255-character title produced a 257-character slug: Slug.ensure_unique/2 appended -2 to a slug already at the column’s ceiling. Both slugify/1 and unique_slug/2 now pass max_length:, which trims the base to make room for the suffix — the hazard core’s own Slug documents.
    • PostGroup and PostTag accepted an explicit slug wider than their columns (generated ones are safe — they derive from a name capped at 100).

Posts 0.5.0. Install or update: {:phoenix_kit_posts, "~> 0.5"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.