create-nextblock 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-nextblock.js +23 -2
- package/docker-template/.dockerignore +2 -1
- package/package.json +1 -1
- package/scripts/sync-template.js +97 -0
- package/templates/nextblock-template/.dockerignore +2 -1
- package/templates/nextblock-template/README.md +57 -34
- package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +525 -1
- package/templates/nextblock-template/docs/04-DATABASE-AND-AUTH.md +2 -1
- package/templates/nextblock-template/docs/11-SELF-HOSTED-DOCKER.md +9 -0
- package/templates/nextblock-template/docs/12-VERCEL-DEPLOYMENT.md +8 -0
- package/templates/nextblock-template/docs/13-STAYING-UP-TO-DATE.md +372 -151
- package/templates/nextblock-template/docs/README.md +2 -0
- package/templates/nextblock-template/gitignore +3 -0
- package/templates/nextblock-template/lib/onboarding/status.ts +11 -5
- package/templates/nextblock-template/lib/setup/migrations-bundle.ts +35 -0
- package/templates/nextblock-template/lib/updates/check-upstream.ts +167 -46
- package/templates/nextblock-template/package.json +6 -1
- package/templates/nextblock-template/tools/build-migrate.mjs +102 -209
- package/templates/nextblock-template/tools/lib/migrate-core.mjs +569 -0
- package/templates/nextblock-template/tools/update.mjs +1285 -0
- package/templates/nextblock-template/tsconfig.tsbuildinfo +0 -1
|
@@ -6794,6 +6794,525 @@ CREATE POLICY "Admins insert site script revisions" ON public.site_script_revisi
|
|
|
6794
6794
|
WITH CHECK (((SELECT public.get_current_user_role()) = 'ADMIN'::public.user_role));
|
|
6795
6795
|
|
|
6796
6796
|
|
|
6797
|
+
-- >>> FROM: 00000000000020_updating_article.sql <<<
|
|
6798
|
+
-- 00000000000020_updating_article.sql
|
|
6799
|
+
-- Seeds the "How Updating NextBlock Works" guide as an EN/FR twin pair, the companion
|
|
6800
|
+
-- to the install guide seeded in the baseline (00000000000003, slugs 'how-to-setup-nextblock'
|
|
6801
|
+
-- / 'comment-configurer-nextblock'). It documents the single \`npm run update\` command
|
|
6802
|
+
-- across all four install paths — one-click Vercel, npm create → Docker, npm create →
|
|
6803
|
+
-- managed cloud, and the cloned monorepo.
|
|
6804
|
+
--
|
|
6805
|
+
-- Forward-only and idempotent by construction:
|
|
6806
|
+
-- * posts carries UNIQUE (language_id, slug), so the inserts use ON CONFLICT DO NOTHING;
|
|
6807
|
+
-- * blocks has no natural unique key, so the body insert is guarded on NOT EXISTS;
|
|
6808
|
+
-- * ids are never hardcoded — posts.id and blocks.id are identity columns and a live
|
|
6809
|
+
-- database has real editor-created rows occupying the low ids the baseline used.
|
|
6810
|
+
-- * the feature image is looked up rather than asserted, so a site that deleted the
|
|
6811
|
+
-- seeded media row still gets the article (with no cover) instead of a failed migration.
|
|
6812
|
+
--
|
|
6813
|
+
-- Because the sandbox reset payload and the /setup wizard's embedded bundle are both
|
|
6814
|
+
-- generated FROM this directory, the article reaches a fresh install and every hourly
|
|
6815
|
+
-- sandbox reset with no extra wiring — regenerate them with \`npm run generate:sandbox\`
|
|
6816
|
+
-- and \`npm run generate:migrations-bundle\`.
|
|
6817
|
+
--
|
|
6818
|
+
-- blocks.content is JSONB written with PostgreSQL dollar-quoting (same style as 006/008)
|
|
6819
|
+
-- so the HTML can use ordinary single-quoted class attributes without quote doubling.
|
|
6820
|
+
|
|
6821
|
+
DO $body$
|
|
6822
|
+
DECLARE
|
|
6823
|
+
v_group uuid := 'c0d3f1a2-8b47-4e19-9a52-7f6b1d4e8c30';
|
|
6824
|
+
v_image uuid;
|
|
6825
|
+
v_en_post integer;
|
|
6826
|
+
v_fr_post integer;
|
|
6827
|
+
BEGIN
|
|
6828
|
+
SELECT id INTO v_image
|
|
6829
|
+
FROM public.media
|
|
6830
|
+
WHERE id = '641ddf75-5c90-41df-8b83-e7c298f30a6a'::uuid;
|
|
6831
|
+
|
|
6832
|
+
---------------------------------------------------------------------------
|
|
6833
|
+
-- English
|
|
6834
|
+
---------------------------------------------------------------------------
|
|
6835
|
+
INSERT INTO public.posts (
|
|
6836
|
+
language_id, author_id, title, slug, label, excerpt, subtitle, status,
|
|
6837
|
+
published_at, meta_title, meta_description, feature_image_id, version,
|
|
6838
|
+
translation_group_id
|
|
6839
|
+
)
|
|
6840
|
+
SELECT
|
|
6841
|
+
1, NULL,
|
|
6842
|
+
'How Updating NextBlock Works: One Command for Every Install',
|
|
6843
|
+
'how-updating-works',
|
|
6844
|
+
'Maintenance',
|
|
6845
|
+
'However you installed NextBlock — one-click Vercel, the CLI, Docker or a git clone — a single npm run update brings the code, the dependencies and the database schema forward together.',
|
|
6846
|
+
'Automatic upstream syncing on Vercel, and one command everywhere else: what npm run update does, what it never touches, and how to roll it back.',
|
|
6847
|
+
'published', now(),
|
|
6848
|
+
'How to Update NextBlock — One Command for Every Install',
|
|
6849
|
+
'Update NextBlock in one step. npm run update pulls new code, installs dependencies and applies pending database migrations on Vercel, Docker, CLI and git-clone installs alike.',
|
|
6850
|
+
v_image, 1, v_group
|
|
6851
|
+
WHERE NOT EXISTS (
|
|
6852
|
+
SELECT 1 FROM public.posts WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
6853
|
+
);
|
|
6854
|
+
|
|
6855
|
+
SELECT id INTO v_en_post
|
|
6856
|
+
FROM public.posts
|
|
6857
|
+
WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
6858
|
+
ORDER BY id
|
|
6859
|
+
LIMIT 1;
|
|
6860
|
+
|
|
6861
|
+
IF v_en_post IS NOT NULL AND NOT EXISTS (
|
|
6862
|
+
SELECT 1 FROM public.blocks WHERE post_id = v_en_post
|
|
6863
|
+
) THEN
|
|
6864
|
+
INSERT INTO public.blocks (post_id, language_id, block_type, content, "order")
|
|
6865
|
+
VALUES (v_en_post, 1, 'text', $nben$
|
|
6866
|
+
{"html_content":"<p class='text-lg leading-8 text-slate-700 dark:text-slate-300'>NextBlock ships improvements continuously — new blocks, editor fixes, security patches, and occasionally a database change that the new code depends on. Keeping up with all of that used to mean knowing which of the four install paths you were on. It no longer does. Every NextBlock project, however it was created, understands one command:</p>\\n\\n<div class='my-10 overflow-hidden rounded-[2rem] border border-slate-800 bg-slate-950 shadow-2xl'>\\n <div class='flex items-center gap-2 border-b border-white/10 px-5 py-3'>\\n <span class='h-3 w-3 rounded-full bg-red-400/70'></span>\\n <span class='h-3 w-3 rounded-full bg-yellow-400/70'></span>\\n <span class='h-3 w-3 rounded-full bg-green-400/70'></span>\\n <span class='ml-3 text-xs font-mono text-slate-400'>your project</span>\\n </div>\\n <div class='px-6 py-8 text-center'>\\n <p class='mt-0 mb-2 font-mono text-2xl sm:text-3xl font-semibold text-emerald-300'>npm run update</p>\\n <p class='mb-0 text-sm text-slate-400'>Code · dependencies · database schema — in that order, in one step.</p>\\n </div>\\n</div>\\n\\n<p>It figures out which kind of install it is running inside, picks the right source for new code, installs the matching dependencies, and then applies any database migrations the new version needs. If you would rather look before you leap, <code>npm run update -- --check</code> reports exactly what would change and touches nothing.</p>\\n\\n<h2 id='the-four-paths'>The four install paths, and how each one gets updates</h2>\\n<p class='text-slate-600 dark:text-slate-400'>These map one-to-one onto the four options in <a href='/article/how-to-setup-nextblock'>the install guide</a>. The command is the same everywhere; what differs is where the new code comes from.</p>\\n\\n<div class='grid gap-5 md:grid-cols-2 my-8'>\\n <a href='#vercel' class='block rounded-[1.75rem] border border-blue-200 bg-blue-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-blue-500/20 dark:bg-blue-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-blue-600 text-sm font-bold text-white'>1</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-blue-700 dark:text-blue-200'>Fully automatic</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>One-click Vercel & GitHub forks</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>A daily workflow merges upstream into your repository and Vercel redeploys. You do nothing.</p>\\n </a>\\n <a href='#docker' class='block rounded-[1.75rem] border border-amber-200 bg-amber-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-amber-500/20 dark:bg-amber-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-amber-500 text-sm font-bold text-white'>2</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-amber-700 dark:text-amber-200'>One command</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>npm create nextblock → Docker</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>Update, then rebuild the local stack. Your Postgres and media volumes survive untouched.</p>\\n </a>\\n <a href='#cloud' class='block rounded-[1.75rem] border border-violet-200 bg-violet-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-violet-500/20 dark:bg-violet-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-violet-600 text-sm font-bold text-white'>3</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-violet-700 dark:text-violet-200'>One command</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>npm create nextblock → Supabase</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>New framework files come from npm; your own pages, routes and content are left alone.</p>\\n </a>\\n <a href='#clone' class='block rounded-[1.75rem] border border-emerald-200 bg-emerald-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-emerald-500/20 dark:bg-emerald-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-emerald-600 text-sm font-bold text-white'>4</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-emerald-700 dark:text-emerald-200'>One command</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>git clone the monorepo</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>A guarded git pull or upstream merge, then dependencies and migrations. No manual steps.</p>\\n </a>\\n</div>\\n\\n<h2 id='vercel'>1. One-click Vercel and GitHub forks — hands-off</h2>\\n<p>This path updates itself. When you deployed, NextBlock created a repository you own; the dashboard’s <strong>Connect GitHub</strong> onboarding step installs a workflow into it that runs <strong>every day at midnight UTC</strong> and can also be triggered by hand from your repository’s <strong>Actions</strong> tab.</p>\\n<ol class='space-y-2'>\\n <li>The workflow merges the latest upstream NextBlock into your deploy branch.</li>\\n <li>A clean merge is pushed to your branch, which triggers an ordinary Vercel deployment.</li>\\n <li>During that production build, NextBlock applies any pending database migrations <em>before</em> the app is built — so new code never runs against an old schema.</li>\\n <li>If the merge conflicts, nothing is pushed. The workflow opens a GitHub issue instead, and your CMS dashboard shows an amber banner linking straight to it. Resolve it, close the issue, and the banner clears itself.</li>\\n</ol>\\n<div class='rounded-3xl border border-emerald-200 bg-emerald-50/80 p-6 my-8 dark:border-emerald-500/20 dark:bg-emerald-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-emerald-700 dark:text-emerald-200'>Make the repository public</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>A public repository is completely zero-config. On a private one, add a <code>NEXTBLOCK_GITHUB_TOKEN</code> environment variable with read access to issues so the conflict banner still works — and note that Vercel’s free Hobby plan refuses to auto-deploy automated commits on private repositories, so the merge would land without deploying.</p>\\n</div>\\n<p>Working on a local clone of that fork? <code>npm run update</code> does the same merge on your machine, adding an <code>upstream</code> remote if it is missing, then installs dependencies and applies migrations.</p>\\n\\n<h2 id='docker'>2. npm create nextblock → Docker — update, then rebuild</h2>\\n<p>From your project directory:</p>\\n<pre><code>npm run update\\nnpm run docker:up</code></pre>\\n<p>The first command refreshes the application, its dependencies and the schema; the second rebuilds and restarts the containers. Your database and media live in Docker volumes and are never touched by either step — <code>docker:up</code> rebuilds images, not data.</p>\\n\\n<h2 id='cloud'>3. npm create nextblock → managed Supabase — one command</h2>\\n<pre><code>npm run update\\nnpm run build\\nnpm start</code></pre>\\n<p>Your project is a standalone Next.js app, so new framework code is fetched from the published <code>create-nextblock</code> package on npm — the exact artifact your project was scaffolded from, versioned in lockstep with the release. NextBlock refreshes the files it owns, merges the new dependency versions into your <code>package.json</code>, runs <code>npm install</code>, and then applies migrations.</p>\\n<div class='rounded-3xl border border-violet-200 bg-violet-50/80 p-6 my-8 dark:border-violet-500/20 dark:bg-violet-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-violet-700 dark:text-violet-200'>Deploying to Vercel from this project</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>Run <code>npm run update</code> locally, commit the result, and push. Your production build applies any pending migrations on the way up, exactly as it does for one-click installs.</p>\\n</div>\\n\\n<h2 id='clone'>4. The cloned monorepo — one command</h2>\\n<pre><code>npm run update</code></pre>\\n<p>In a clone of the NextBlock repository this fast-forwards your checkout, reinstalls workspace dependencies and applies pending migrations. It refuses to run over uncommitted changes and tells you how to stash them first, so an update can never silently eat work in progress. If you have local commits, it stops and points you at <code>git pull --rebase</code> rather than guessing.</p>\\n\\n<h2 id='what-it-does'>What <code>npm run update</code> actually does</h2>\\n<ol class='space-y-2'>\\n <li><strong>Identifies the install.</strong> Monorepo or standalone app; git-backed or npm-backed; Docker or not.</li>\\n <li><strong>Updates the code</strong> from the right source — an upstream git merge, a fast-forward pull, or the published <code>create-nextblock</code> package.</li>\\n <li><strong>Installs dependencies</strong> with <code>npm install</code>, so the code and the packages it imports move together.</li>\\n <li><strong>Refreshes the migration files</strong> shipped inside <code>@nextblock-cms/db</code>, so the newest schema changes are on disk before anything is applied.</li>\\n <li><strong>Applies pending migrations</strong>, listing them first and asking before it writes.</li>\\n <li><strong>Clears the dashboard’s update banner</strong> once the new version is really in place.</li>\\n</ol>\\n\\n<h3>Options</h3>\\n<div class='overflow-x-auto my-6'>\\n<table class='w-full text-left text-sm'>\\n <thead><tr class='border-b border-slate-200 dark:border-white/10'><th class='py-3 pr-4 font-semibold'>Command</th><th class='py-3 font-semibold'>What it does</th></tr></thead>\\n <tbody class='align-top'>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update</code></td><td class='py-3'>Code, dependencies and schema.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --check</code></td><td class='py-3'>Report what would change. Writes nothing.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --yes</code></td><td class='py-3'>Skip the confirmation prompts. Useful in CI.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --db-only</code></td><td class='py-3'>Apply pending migrations and nothing else.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --skip-db</code></td><td class='py-3'>Update code and dependencies, leave the database alone.</td></tr>\\n <tr><td class='py-3 pr-4'><code>npm run update -- --force</code></td><td class='py-3'>Run even when you are already on the latest version.</td></tr>\\n </tbody>\\n</table>\\n</div>\\n\\n<h2 id='database'>What happens to your database</h2>\\n<p>Schema changes are <strong>forward-only</strong>. NextBlock never rewrites or replays a migration that has already run: each one is applied and recorded in the same transaction, so a failure rolls back cleanly and leaves the database exactly as it was. Already-applied migrations are skipped by version, which makes re-running an update completely safe.</p>\\n<p>Migrations change <em>structure</em> — tables, columns, indexes, permissions. Your pages, posts, products, media and users are yours; the update never deletes or rewrites them.</p>\\n<div class='rounded-3xl border border-blue-200 bg-blue-50/80 p-6 my-8 dark:border-blue-500/20 dark:bg-blue-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-blue-700 dark:text-blue-200'>Belt and braces</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>Before a big jump on a production site, take a database snapshot — Supabase does daily backups on paid plans, and you can trigger one on demand from the Supabase dashboard. Then run <code>npm run update -- --check</code> to see the pending list before you commit to it.</p>\\n</div>\\n\\n<h2 id='safety'>If something goes wrong</h2>\\n<ul class='space-y-2'>\\n <li><strong>Standalone projects:</strong> every framework file the update replaces is copied first into a timestamped folder under <code>.nextblock-backup/</code> in your project. Nothing is deleted, so files you added yourself are never removed.</li>\\n <li><strong>Git-backed installs:</strong> the update is an ordinary commit. <code>git log</code> shows it and <code>git revert</code> undoes it.</li>\\n <li><strong>A conflicted merge</strong> is aborted automatically — your working tree is left exactly as it was, with instructions printed for resolving it by hand.</li>\\n <li><strong>A failed migration</strong> rolls back. Fix the cause and re-run; nothing half-applied is left behind.</li>\\n</ul>\\n<p>If you have customised a file that NextBlock owns — something under <code>app/</code>, <code>components/</code> or <code>lib/</code> — the update will replace it and back up your version. Diff the backup afterwards to bring your change forward. Customisations that live in your own new files, in the CMS, or in <code>.env</code> are never affected.</p>\\n\\n<h2 id='knowing'>Knowing when there is something to update</h2>\\n<p>You do not have to poll. NextBlock checks in the background while you use the CMS and raises a dashboard banner when a newer version is published, telling you which version you are on and what is available. Administrators can also just run <code>npm run update -- --check</code> at any time.</p>\\n\\n<h2 id='faq'>Update FAQ</h2>\\n<h3>Will updating overwrite my content or settings?</h3>\\n<p>No. Content, media, users and settings live in your database; site configuration lives in your environment variables. The update touches application code, dependencies and schema structure only.</p>\\n<h3>Do I have to update every release?</h3>\\n<p>No, though staying close to the latest release keeps you on security fixes and makes each jump smaller. Updates apply in sequence, so skipping several versions still lands correctly.</p>\\n<h3>Can I run it in CI?</h3>\\n<p>Yes — <code>npm run update -- --yes</code> never prompts, and it exits non-zero if the schema step fails so a pipeline can catch it.</p>\\n<h3>What if my project has no database connection configured?</h3>\\n<p>Code and dependencies still update; the schema step is skipped with a warning telling you which environment variable to set. Re-run <code>npm run update -- --db-only</code> once it is configured.</p>\\n<h3>I am on the one-click Vercel deploy — do I need to run anything?</h3>\\n<p>No. That path is fully automatic. The command exists for when you want an update <em>now</em> rather than at midnight, or when you are working on a local clone.</p>\\n\\n<div class='rounded-[2rem] border border-slate-200/80 bg-slate-50 p-8 my-12 text-center dark:border-white/10 dark:bg-white/5'>\\n <p class='mt-0 text-2xl font-semibold text-slate-900 dark:text-white'>One command, every install.</p>\\n <p class='text-sm text-slate-600 dark:text-slate-300'>New to NextBlock? Start with the install guide — then never think about upgrades again.</p>\\n <div class='mt-5 flex flex-wrap justify-center gap-3'>\\n <a href='/article/how-to-setup-nextblock' class='inline-flex items-center rounded-full bg-slate-900 px-6 py-3 text-sm font-semibold text-white no-underline shadow-lg hover:bg-slate-700 dark:bg-white dark:text-slate-900 dark:hover:bg-slate-200'>Read the install guide</a>\\n <a href='https://github.com/nextblock-cms/nextblock' target='_blank' rel='noopener' class='inline-flex items-center rounded-full border border-slate-300 px-6 py-3 text-sm font-semibold text-slate-700 no-underline hover:border-slate-500 dark:border-white/20 dark:text-slate-200 dark:hover:border-white/50'>View on GitHub</a>\\n </div>\\n</div>"}
|
|
6867
|
+
$nben$::jsonb, 0);
|
|
6868
|
+
END IF;
|
|
6869
|
+
|
|
6870
|
+
---------------------------------------------------------------------------
|
|
6871
|
+
-- French
|
|
6872
|
+
---------------------------------------------------------------------------
|
|
6873
|
+
INSERT INTO public.posts (
|
|
6874
|
+
language_id, author_id, title, slug, label, excerpt, subtitle, status,
|
|
6875
|
+
published_at, meta_title, meta_description, feature_image_id, version,
|
|
6876
|
+
translation_group_id
|
|
6877
|
+
)
|
|
6878
|
+
SELECT
|
|
6879
|
+
2, NULL,
|
|
6880
|
+
'Les mises à jour de NextBlock : une seule commande, quelle que soit l''installation',
|
|
6881
|
+
'comment-fonctionnent-les-mises-a-jour',
|
|
6882
|
+
'Maintenance',
|
|
6883
|
+
'Quelle que soit votre installation — Vercel en un clic, le CLI, Docker ou un git clone — une seule commande npm run update fait avancer ensemble le code, les dépendances et le schéma de base de données.',
|
|
6884
|
+
'Synchronisation automatique sur Vercel, et une seule commande partout ailleurs : ce que fait npm run update, ce qu''il ne touche jamais, et comment revenir en arrière.',
|
|
6885
|
+
'published', now(),
|
|
6886
|
+
'Mettre à jour NextBlock — une commande pour toutes les installations',
|
|
6887
|
+
'Mettez NextBlock à jour en une étape. npm run update récupère le nouveau code, installe les dépendances et applique les migrations en attente, sur Vercel, Docker, CLI et git clone.',
|
|
6888
|
+
v_image, 1, v_group
|
|
6889
|
+
WHERE NOT EXISTS (
|
|
6890
|
+
SELECT 1 FROM public.posts
|
|
6891
|
+
WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
6892
|
+
);
|
|
6893
|
+
|
|
6894
|
+
SELECT id INTO v_fr_post
|
|
6895
|
+
FROM public.posts
|
|
6896
|
+
WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
6897
|
+
ORDER BY id
|
|
6898
|
+
LIMIT 1;
|
|
6899
|
+
|
|
6900
|
+
IF v_fr_post IS NOT NULL AND NOT EXISTS (
|
|
6901
|
+
SELECT 1 FROM public.blocks WHERE post_id = v_fr_post
|
|
6902
|
+
) THEN
|
|
6903
|
+
INSERT INTO public.blocks (post_id, language_id, block_type, content, "order")
|
|
6904
|
+
VALUES (v_fr_post, 2, 'text', $nbfr$
|
|
6905
|
+
{"html_content":"<p class='text-lg leading-8 text-slate-700 dark:text-slate-300'>NextBlock évolue en continu — nouveaux blocs, corrections de l'éditeur, correctifs de sécurité, et parfois une modification de la base de données dont le nouveau code dépend. Suivre tout cela supposait autrefois de savoir laquelle des quatre méthodes d'installation vous aviez utilisée. Ce n'est plus le cas. Tout projet NextBlock, quelle que soit sa création, comprend une seule commande :</p>\\n\\n<div class='my-10 overflow-hidden rounded-[2rem] border border-slate-800 bg-slate-950 shadow-2xl'>\\n <div class='flex items-center gap-2 border-b border-white/10 px-5 py-3'>\\n <span class='h-3 w-3 rounded-full bg-red-400/70'></span>\\n <span class='h-3 w-3 rounded-full bg-yellow-400/70'></span>\\n <span class='h-3 w-3 rounded-full bg-green-400/70'></span>\\n <span class='ml-3 text-xs font-mono text-slate-400'>votre projet</span>\\n </div>\\n <div class='px-6 py-8 text-center'>\\n <p class='mt-0 mb-2 font-mono text-2xl sm:text-3xl font-semibold text-emerald-300'>npm run update</p>\\n <p class='mb-0 text-sm text-slate-400'>Code · dépendances · schéma de base de données — dans cet ordre, en une seule étape.</p>\\n </div>\\n</div>\\n\\n<p>La commande détermine dans quel type d'installation elle s'exécute, choisit la bonne source pour le nouveau code, installe les dépendances correspondantes, puis applique les migrations dont la nouvelle version a besoin. Si vous préférez regarder avant de sauter, <code>npm run update -- --check</code> indique exactement ce qui changerait sans rien modifier.</p>\\n\\n<h2 id='the-four-paths'>Les quatre installations et leurs mises à jour</h2>\\n<p class='text-slate-600 dark:text-slate-400'>Elles correspondent une à une aux quatre options du <a href='/article/comment-configurer-nextblock'>guide d'installation</a>. La commande est la même partout ; seule la provenance du nouveau code change.</p>\\n\\n<div class='grid gap-5 md:grid-cols-2 my-8'>\\n <a href='#vercel' class='block rounded-[1.75rem] border border-blue-200 bg-blue-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-blue-500/20 dark:bg-blue-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-blue-600 text-sm font-bold text-white'>1</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-blue-700 dark:text-blue-200'>Entièrement automatique</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>Vercel en un clic et forks GitHub</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>Un workflow quotidien fusionne les nouveautés dans votre dépôt et Vercel redéploie. Vous n'avez rien à faire.</p>\\n </a>\\n <a href='#docker' class='block rounded-[1.75rem] border border-amber-200 bg-amber-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-amber-500/20 dark:bg-amber-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-amber-500 text-sm font-bold text-white'>2</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-amber-700 dark:text-amber-200'>Une commande</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>npm create nextblock → Docker</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>Mettez à jour, puis reconstruisez la pile locale. Vos volumes Postgres et médias restent intacts.</p>\\n </a>\\n <a href='#cloud' class='block rounded-[1.75rem] border border-violet-200 bg-violet-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-violet-500/20 dark:bg-violet-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-violet-600 text-sm font-bold text-white'>3</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-violet-700 dark:text-violet-200'>Une commande</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>npm create nextblock → Supabase</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>Les nouveaux fichiers viennent de npm ; vos pages, routes et contenus ne sont pas touchés.</p>\\n </a>\\n <a href='#clone' class='block rounded-[1.75rem] border border-emerald-200 bg-emerald-50/70 p-6 no-underline transition-shadow hover:shadow-lg dark:border-emerald-500/20 dark:bg-emerald-500/10'>\\n <span class='flex h-9 w-9 items-center justify-center rounded-full bg-emerald-600 text-sm font-bold text-white'>4</span>\\n <p class='mt-4 mb-0 text-xs font-semibold uppercase tracking-[0.22em] text-emerald-700 dark:text-emerald-200'>Une commande</p>\\n <h3 class='mt-2 mb-2 text-xl font-semibold text-slate-900 dark:text-white'>git clone du monorepo</h3>\\n <p class='mb-0 text-sm leading-6 text-slate-600 dark:text-slate-300'>Un pull ou une fusion protégée, puis les dépendances et les migrations. Aucune étape manuelle.</p>\\n </a>\\n</div>\\n\\n<h2 id='vercel'>1. Vercel en un clic et forks GitHub — sans intervention</h2>\\n<p>Ce chemin se met à jour tout seul. Lors du déploiement, NextBlock a créé un dépôt qui vous appartient ; l'étape <strong>Connect GitHub</strong> du tableau de bord y installe un workflow qui s'exécute <strong>chaque jour à minuit UTC</strong> et peut aussi être lancé à la demande depuis l'onglet <strong>Actions</strong> de votre dépôt.</p>\\n<ol class='space-y-2'>\\n <li>Le workflow fusionne la dernière version de NextBlock dans votre branche de déploiement.</li>\\n <li>Une fusion propre est poussée sur votre branche, ce qui déclenche un déploiement Vercel normal.</li>\\n <li>Pendant ce build de production, NextBlock applique les migrations en attente <em>avant</em> de construire l'application — le nouveau code ne tourne donc jamais sur un ancien schéma.</li>\\n <li>En cas de conflit, rien n'est poussé. Le workflow ouvre une issue GitHub et votre tableau de bord affiche une bannière ambre qui pointe dessus. Résolvez, fermez l'issue, et la bannière disparaît d'elle-même.</li>\\n</ol>\\n<div class='rounded-3xl border border-emerald-200 bg-emerald-50/80 p-6 my-8 dark:border-emerald-500/20 dark:bg-emerald-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-emerald-700 dark:text-emerald-200'>Rendez le dépôt public</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>Un dépôt public ne demande aucune configuration. Sur un dépôt privé, ajoutez une variable d'environnement <code>NEXTBLOCK_GITHUB_TOKEN</code> avec un accès en lecture aux issues pour que la bannière de conflit fonctionne — et sachez que l'offre gratuite Hobby de Vercel refuse de déployer automatiquement les commits automatisés sur un dépôt privé.</p>\\n</div>\\n<p>Vous travaillez sur un clone local de ce fork ? <code>npm run update</code> effectue la même fusion sur votre machine, en ajoutant le dépôt <code>upstream</code> s'il manque, puis installe les dépendances et applique les migrations.</p>\\n\\n<h2 id='docker'>2. npm create nextblock → Docker — mettre à jour puis reconstruire</h2>\\n<p>Depuis le dossier de votre projet :</p>\\n<pre><code>npm run update\\nnpm run docker:up</code></pre>\\n<p>La première commande met à jour l'application, ses dépendances et le schéma ; la seconde reconstruit et redémarre les conteneurs. Votre base de données et vos médias vivent dans des volumes Docker et ne sont touchés ni par l'une ni par l'autre — <code>docker:up</code> reconstruit des images, pas des données.</p>\\n\\n<h2 id='cloud'>3. npm create nextblock → Supabase géré — une commande</h2>\\n<pre><code>npm run update\\nnpm run build\\nnpm start</code></pre>\\n<p>Votre projet est une application Next.js autonome : le nouveau code provient donc du paquet <code>create-nextblock</code> publié sur npm — exactement l'artefact à partir duquel votre projet a été généré, versionné en phase avec la release. NextBlock rafraîchit les fichiers qui lui appartiennent, fusionne les nouvelles versions de dépendances dans votre <code>package.json</code>, lance <code>npm install</code>, puis applique les migrations.</p>\\n<div class='rounded-3xl border border-violet-200 bg-violet-50/80 p-6 my-8 dark:border-violet-500/20 dark:bg-violet-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-violet-700 dark:text-violet-200'>Vous déployez ce projet sur Vercel ?</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>Lancez <code>npm run update</code> en local, validez le résultat et poussez. Votre build de production applique les migrations en attente au passage, exactement comme pour les installations en un clic.</p>\\n</div>\\n\\n<h2 id='clone'>4. Le monorepo cloné — une commande</h2>\\n<pre><code>npm run update</code></pre>\\n<p>Dans un clone du dépôt NextBlock, la commande met votre copie à jour, réinstalle les dépendances du workspace et applique les migrations en attente. Elle refuse de s'exécuter par-dessus des modifications non validées et vous explique comment les mettre de côté : une mise à jour ne peut donc jamais faire disparaître du travail en cours. Si vous avez des commits locaux, elle s'arrête et vous oriente vers <code>git pull --rebase</code> plutôt que de deviner.</p>\\n\\n<h2 id='what-it-does'>Ce que fait réellement <code>npm run update</code></h2>\\n<ol class='space-y-2'>\\n <li><strong>Identifie l'installation.</strong> Monorepo ou application autonome ; basée sur git ou sur npm ; Docker ou non.</li>\\n <li><strong>Met à jour le code</strong> depuis la bonne source — fusion git, pull en avance rapide, ou le paquet <code>create-nextblock</code> publié.</li>\\n <li><strong>Installe les dépendances</strong> avec <code>npm install</code>, pour que le code et les paquets qu'il importe avancent ensemble.</li>\\n <li><strong>Rafraîchit les fichiers de migration</strong> livrés dans <code>@nextblock-cms/db</code>, afin que les dernières évolutions du schéma soient sur le disque avant toute application.</li>\\n <li><strong>Applique les migrations en attente</strong>, en les listant d'abord et en demandant confirmation.</li>\\n <li><strong>Efface la bannière de mise à jour</strong> du tableau de bord une fois la nouvelle version réellement en place.</li>\\n</ol>\\n\\n<h3>Options</h3>\\n<div class='overflow-x-auto my-6'>\\n<table class='w-full text-left text-sm'>\\n <thead><tr class='border-b border-slate-200 dark:border-white/10'><th class='py-3 pr-4 font-semibold'>Commande</th><th class='py-3 font-semibold'>Effet</th></tr></thead>\\n <tbody class='align-top'>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update</code></td><td class='py-3'>Code, dépendances et schéma.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --check</code></td><td class='py-3'>Indique ce qui changerait. N'écrit rien.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --yes</code></td><td class='py-3'>Sans confirmation. Pratique en CI.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --db-only</code></td><td class='py-3'>Applique uniquement les migrations en attente.</td></tr>\\n <tr class='border-b border-slate-100 dark:border-white/5'><td class='py-3 pr-4'><code>npm run update -- --skip-db</code></td><td class='py-3'>Met à jour le code et les dépendances, sans toucher à la base.</td></tr>\\n <tr><td class='py-3 pr-4'><code>npm run update -- --force</code></td><td class='py-3'>S'exécute même si vous êtes déjà à jour.</td></tr>\\n </tbody>\\n</table>\\n</div>\\n\\n<h2 id='database'>Ce qui arrive à votre base de données</h2>\\n<p>Les évolutions du schéma sont <strong>uniquement additives</strong>. NextBlock ne réécrit ni ne rejoue jamais une migration déjà appliquée : chacune est appliquée et enregistrée dans la même transaction, si bien qu'un échec est annulé proprement et laisse la base exactement dans son état initial. Les migrations déjà appliquées sont ignorées par numéro de version, ce qui rend une nouvelle exécution totalement sûre.</p>\\n<p>Les migrations modifient la <em>structure</em> — tables, colonnes, index, permissions. Vos pages, articles, produits, médias et utilisateurs vous appartiennent : la mise à jour ne les supprime ni ne les réécrit.</p>\\n<div class='rounded-3xl border border-blue-200 bg-blue-50/80 p-6 my-8 dark:border-blue-500/20 dark:bg-blue-500/10'>\\n <p class='mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-blue-700 dark:text-blue-200'>Par précaution</p>\\n <p class='mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200'>Avant un grand saut sur un site en production, prenez une sauvegarde de la base — Supabase en réalise quotidiennement sur les offres payantes, et vous pouvez en déclencher une à la demande depuis son tableau de bord. Lancez ensuite <code>npm run update -- --check</code> pour voir la liste des migrations en attente.</p>\\n</div>\\n\\n<h2 id='safety'>En cas de problème</h2>\\n<ul class='space-y-2'>\\n <li><strong>Projets autonomes :</strong> chaque fichier remplacé est d'abord copié dans un dossier horodaté sous <code>.nextblock-backup/</code> dans votre projet. Rien n'est supprimé : les fichiers que vous avez ajoutés ne disparaissent jamais.</li>\\n <li><strong>Installations basées sur git :</strong> la mise à jour est un commit ordinaire. <code>git log</code> l'affiche et <code>git revert</code> l'annule.</li>\\n <li><strong>Une fusion en conflit</strong> est annulée automatiquement — votre copie de travail reste intacte, avec les instructions pour résoudre à la main.</li>\\n <li><strong>Une migration en échec</strong> est annulée. Corrigez la cause et relancez : rien ne reste à moitié appliqué.</li>\\n</ul>\\n<p>Si vous avez personnalisé un fichier appartenant à NextBlock — sous <code>app/</code>, <code>components/</code> ou <code>lib/</code> — la mise à jour le remplacera en sauvegardant votre version. Comparez ensuite la sauvegarde pour reporter votre modification. Les personnalisations qui vivent dans vos propres fichiers, dans le CMS ou dans <code>.env</code> ne sont jamais affectées.</p>\\n\\n<h2 id='knowing'>Savoir qu'une mise à jour est disponible</h2>\\n<p>Inutile de surveiller. NextBlock vérifie en arrière-plan pendant que vous utilisez le CMS et affiche une bannière sur le tableau de bord dès qu'une version plus récente est publiée, en indiquant votre version actuelle et celle disponible. Les administrateurs peuvent aussi lancer <code>npm run update -- --check</code> à tout moment.</p>\\n\\n<h2 id='faq'>FAQ des mises à jour</h2>\\n<h3>La mise à jour va-t-elle écraser mon contenu ou mes réglages ?</h3>\\n<p>Non. Contenus, médias, utilisateurs et réglages vivent dans votre base de données ; la configuration du site vit dans vos variables d'environnement. La mise à jour ne touche que le code, les dépendances et la structure du schéma.</p>\\n<h3>Dois-je installer chaque version ?</h3>\\n<p>Non, mais rester proche de la dernière version vous garantit les correctifs de sécurité et rend chaque saut plus petit. Les migrations s'appliquent dans l'ordre : sauter plusieurs versions fonctionne malgré tout.</p>\\n<h3>Puis-je l'exécuter en CI ?</h3>\\n<p>Oui — <code>npm run update -- --yes</code> ne pose aucune question et renvoie un code d'erreur si l'étape schéma échoue, pour qu'un pipeline puisse le détecter.</p>\\n<h3>Et si aucune connexion à la base n'est configurée ?</h3>\\n<p>Le code et les dépendances sont tout de même mis à jour ; l'étape schéma est ignorée avec un avertissement indiquant la variable d'environnement à définir. Relancez ensuite <code>npm run update -- --db-only</code>.</p>\\n<h3>Je suis sur le déploiement Vercel en un clic — dois-je lancer quelque chose ?</h3>\\n<p>Non. Ce chemin est entièrement automatique. La commande existe pour mettre à jour <em>tout de suite</em> plutôt qu'à minuit, ou lorsque vous travaillez sur un clone local.</p>\\n\\n<div class='rounded-[2rem] border border-slate-200/80 bg-slate-50 p-8 my-12 text-center dark:border-white/10 dark:bg-white/5'>\\n <p class='mt-0 text-2xl font-semibold text-slate-900 dark:text-white'>Une commande, toutes les installations.</p>\\n <p class='text-sm text-slate-600 dark:text-slate-300'>Vous débutez avec NextBlock ? Commencez par le guide d'installation — puis oubliez les mises à jour.</p>\\n <div class='mt-5 flex flex-wrap justify-center gap-3'>\\n <a href='/article/comment-configurer-nextblock' class='inline-flex items-center rounded-full bg-slate-900 px-6 py-3 text-sm font-semibold text-white no-underline shadow-lg hover:bg-slate-700 dark:bg-white dark:text-slate-900 dark:hover:bg-slate-200'>Lire le guide d'installation</a>\\n <a href='https://github.com/nextblock-cms/nextblock' target='_blank' rel='noopener' class='inline-flex items-center rounded-full border border-slate-300 px-6 py-3 text-sm font-semibold text-slate-700 no-underline hover:border-slate-500 dark:border-white/20 dark:text-slate-200 dark:hover:border-white/50'>Voir sur GitHub</a>\\n </div>\\n</div>"}
|
|
6906
|
+
$nbfr$::jsonb, 0);
|
|
6907
|
+
END IF;
|
|
6908
|
+
END
|
|
6909
|
+
$body$;
|
|
6910
|
+
|
|
6911
|
+
-- Revision baseline for the two new posts.
|
|
6912
|
+
--
|
|
6913
|
+
-- 00000000000016 back-fills a 'snapshot' revision for every post that existed WHEN IT
|
|
6914
|
+
-- RAN. On a fresh install migrations run in order, so 016 executes before this file and
|
|
6915
|
+
-- these two posts would be the only ones in the CMS without a restore point. This is the
|
|
6916
|
+
-- same projection as 016 section 3b, scoped to the two slugs.
|
|
6917
|
+
INSERT INTO public.post_revisions (post_id, author_id, version, revision_type, content)
|
|
6918
|
+
SELECT
|
|
6919
|
+
po.id,
|
|
6920
|
+
NULL::uuid,
|
|
6921
|
+
po.version,
|
|
6922
|
+
'snapshot'::public.revision_type,
|
|
6923
|
+
jsonb_build_object(
|
|
6924
|
+
'meta', jsonb_build_object(
|
|
6925
|
+
'title', po.title,
|
|
6926
|
+
'slug', po.slug,
|
|
6927
|
+
'language_id', po.language_id,
|
|
6928
|
+
'status', po.status,
|
|
6929
|
+
'meta_title', po.meta_title,
|
|
6930
|
+
'meta_description', po.meta_description,
|
|
6931
|
+
'custom_canonical', po.custom_canonical,
|
|
6932
|
+
'published_at', to_char(po.published_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'),
|
|
6933
|
+
'feature_image_id', po.feature_image_id,
|
|
6934
|
+
'label', po.label,
|
|
6935
|
+
'excerpt', po.excerpt,
|
|
6936
|
+
'subtitle', po.subtitle
|
|
6937
|
+
),
|
|
6938
|
+
'blocks', COALESCE((
|
|
6939
|
+
SELECT jsonb_agg(
|
|
6940
|
+
jsonb_build_object(
|
|
6941
|
+
'language_id', b.language_id,
|
|
6942
|
+
'block_type', b.block_type,
|
|
6943
|
+
'content', b.content,
|
|
6944
|
+
'order', b."order"
|
|
6945
|
+
) ORDER BY b."order" ASC, b.id ASC
|
|
6946
|
+
)
|
|
6947
|
+
FROM public.blocks b
|
|
6948
|
+
WHERE b.post_id = po.id
|
|
6949
|
+
), '[]'::jsonb)
|
|
6950
|
+
)
|
|
6951
|
+
FROM public.posts po
|
|
6952
|
+
WHERE po.slug IN ('how-updating-works', 'comment-fonctionnent-les-mises-a-jour')
|
|
6953
|
+
AND NOT EXISTS (
|
|
6954
|
+
SELECT 1 FROM public.post_revisions r
|
|
6955
|
+
WHERE r.post_id = po.id
|
|
6956
|
+
AND r.revision_type = 'snapshot'
|
|
6957
|
+
AND r.version <= po.version
|
|
6958
|
+
)
|
|
6959
|
+
ON CONFLICT (post_id, version) DO NOTHING;
|
|
6960
|
+
|
|
6961
|
+
|
|
6962
|
+
-- >>> FROM: 00000000000021_updating_article_git_merge.sql <<<
|
|
6963
|
+
-- 00000000000021_updating_article_git_merge.sql
|
|
6964
|
+
-- Corrects the "How Updating NextBlock Works" article seeded in 00000000000020.
|
|
6965
|
+
--
|
|
6966
|
+
-- That version described the standalone update as "replace the files and keep a backup
|
|
6967
|
+
-- under .nextblock-backup/". The updater now performs a real git 3-way merge instead:
|
|
6968
|
+
-- both template versions are committed into the project's own object database under
|
|
6969
|
+
-- refs/nextblock/{base,head}, and the diff between them is applied with \`git apply --3way\`.
|
|
6970
|
+
-- A developer's edits to framework files are preserved and only genuine overlaps conflict.
|
|
6971
|
+
-- The copy-and-back-up path survives only as the fallback for a project with no git repo,
|
|
6972
|
+
-- no commits, or a dirty tree.
|
|
6973
|
+
--
|
|
6974
|
+
-- 020 is already applied everywhere and never replays, so the copy is corrected here as
|
|
6975
|
+
-- targeted, idempotent string replacements rather than a full re-write of the body: each
|
|
6976
|
+
-- replace() is a no-op once the old sentence is gone, so re-running changes nothing.
|
|
6977
|
+
-- Data-only; no schema change.
|
|
6978
|
+
|
|
6979
|
+
DO $body$
|
|
6980
|
+
DECLARE
|
|
6981
|
+
v_en_post integer;
|
|
6982
|
+
v_fr_post integer;
|
|
6983
|
+
BEGIN
|
|
6984
|
+
SELECT id INTO v_en_post
|
|
6985
|
+
FROM public.posts WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
6986
|
+
ORDER BY id LIMIT 1;
|
|
6987
|
+
|
|
6988
|
+
SELECT id INTO v_fr_post
|
|
6989
|
+
FROM public.posts WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
6990
|
+
ORDER BY id LIMIT 1;
|
|
6991
|
+
|
|
6992
|
+
---------------------------------------------------------------------------
|
|
6993
|
+
-- English
|
|
6994
|
+
---------------------------------------------------------------------------
|
|
6995
|
+
IF v_en_post IS NOT NULL THEN
|
|
6996
|
+
UPDATE public.blocks
|
|
6997
|
+
SET content = jsonb_set(
|
|
6998
|
+
content,
|
|
6999
|
+
'{html_content}',
|
|
7000
|
+
to_jsonb(
|
|
7001
|
+
replace(
|
|
7002
|
+
replace(
|
|
7003
|
+
replace(
|
|
7004
|
+
content->>'html_content',
|
|
7005
|
+
-- 1. the "if something goes wrong" bullet
|
|
7006
|
+
'<li><strong>Standalone projects:</strong> every framework file the update replaces is copied first into a timestamped folder under <code>.nextblock-backup/</code> in your project. Nothing is deleted, so files you added yourself are never removed.</li>',
|
|
7007
|
+
'<li><strong>Standalone projects:</strong> the update is applied as a <strong>git 3-way merge</strong> into your working tree — nothing is committed for you. Review it with <code>git diff</code>, and undo the whole thing with <code>git reset --hard HEAD</code>. Nothing is ever deleted, so files you added yourself are never removed.</li>'
|
|
7008
|
+
),
|
|
7009
|
+
-- 2. the "you customised a framework file" paragraph
|
|
7010
|
+
'<p>If you have customised a file that NextBlock owns — something under <code>app/</code>, <code>components/</code> or <code>lib/</code> — the update will replace it and back up your version. Diff the backup afterwards to bring your change forward. Customisations that live in your own new files, in the CMS, or in <code>.env</code> are never affected.</p>',
|
|
7011
|
+
'<p>If you have customised a file that NextBlock owns — something under <code>app/</code>, <code>components/</code> or <code>lib/</code> — <strong>your edit is kept</strong>. The update merges the upstream change into your version, and only a change that genuinely overlaps yours conflicts, with ordinary <code><<<<<<< ours</code> / <code>>>>>>>> theirs</code> markers. List them with <code>git diff --name-only --diff-filter=U</code> and resolve with <code>git checkout --theirs</code> or <code>--ours</code>. Customisations in your own files, in the CMS, or in <code>.env</code> are never touched at all.</p>'
|
|
7012
|
+
),
|
|
7013
|
+
-- 3. the managed-cloud section
|
|
7014
|
+
'<p>Your project is a standalone Next.js app, so new framework code is fetched from the published <code>create-nextblock</code> package on npm — the exact artifact your project was scaffolded from, versioned in lockstep with the release. NextBlock refreshes the files it owns, merges the new dependency versions into your <code>package.json</code>, runs <code>npm install</code>, and then applies migrations.</p>',
|
|
7015
|
+
'<p>Your project is a standalone Next.js app with no upstream to pull from, so new framework code comes from the published <code>create-nextblock</code> package on npm — the exact artifact your project was scaffolded from, versioned in lockstep with the release. NextBlock fetches both your current version and the new one, and applies the difference between them as a <strong>git 3-way merge</strong>, so the update behaves exactly like a <code>git pull</code>: files you never touched update silently, files you customised keep your changes. It then merges the new dependency versions into your <code>package.json</code>, runs <code>npm install</code>, and applies migrations.</p><p>This needs a git repository with at least one commit and a clean working tree — commit your work before updating. Without that there is nothing to merge against, so the files are copied instead and anything replaced is kept under <code>.nextblock-backup/</code>.</p>'
|
|
7016
|
+
)
|
|
7017
|
+
)
|
|
7018
|
+
),
|
|
7019
|
+
updated_at = now()
|
|
7020
|
+
WHERE post_id = v_en_post
|
|
7021
|
+
AND block_type = 'text';
|
|
7022
|
+
END IF;
|
|
7023
|
+
|
|
7024
|
+
---------------------------------------------------------------------------
|
|
7025
|
+
-- French
|
|
7026
|
+
---------------------------------------------------------------------------
|
|
7027
|
+
IF v_fr_post IS NOT NULL THEN
|
|
7028
|
+
UPDATE public.blocks
|
|
7029
|
+
SET content = jsonb_set(
|
|
7030
|
+
content,
|
|
7031
|
+
'{html_content}',
|
|
7032
|
+
to_jsonb(
|
|
7033
|
+
replace(
|
|
7034
|
+
replace(
|
|
7035
|
+
replace(
|
|
7036
|
+
content->>'html_content',
|
|
7037
|
+
'<li><strong>Projets autonomes :</strong> chaque fichier remplacé est d''abord copié dans un dossier horodaté sous <code>.nextblock-backup/</code> dans votre projet. Rien n''est supprimé : les fichiers que vous avez ajoutés ne disparaissent jamais.</li>',
|
|
7038
|
+
'<li><strong>Projets autonomes :</strong> la mise à jour est appliquée comme une <strong>fusion git à trois voies</strong> dans votre copie de travail — rien n''est validé à votre place. Examinez-la avec <code>git diff</code>, et annulez tout avec <code>git reset --hard HEAD</code>. Rien n''est jamais supprimé : les fichiers que vous avez ajoutés ne disparaissent jamais.</li>'
|
|
7039
|
+
),
|
|
7040
|
+
'<p>Si vous avez personnalisé un fichier appartenant à NextBlock — sous <code>app/</code>, <code>components/</code> ou <code>lib/</code> — la mise à jour le remplacera en sauvegardant votre version. Comparez ensuite la sauvegarde pour reporter votre modification. Les personnalisations qui vivent dans vos propres fichiers, dans le CMS ou dans <code>.env</code> ne sont jamais affectées.</p>',
|
|
7041
|
+
'<p>Si vous avez personnalisé un fichier appartenant à NextBlock — sous <code>app/</code>, <code>components/</code> ou <code>lib/</code> — <strong>votre modification est conservée</strong>. La mise à jour fusionne le changement amont dans votre version, et seul un changement qui chevauche réellement le vôtre entre en conflit, avec les marqueurs habituels <code><<<<<<< ours</code> / <code>>>>>>>> theirs</code>. Listez-les avec <code>git diff --name-only --diff-filter=U</code> et résolvez avec <code>git checkout --theirs</code> ou <code>--ours</code>. Les personnalisations dans vos propres fichiers, dans le CMS ou dans <code>.env</code> ne sont jamais touchées.</p>'
|
|
7042
|
+
),
|
|
7043
|
+
'<p>Votre projet est une application Next.js autonome : le nouveau code provient donc du paquet <code>create-nextblock</code> publié sur npm — exactement l''artefact à partir duquel votre projet a été généré, versionné en phase avec la release. NextBlock rafraîchit les fichiers qui lui appartiennent, fusionne les nouvelles versions de dépendances dans votre <code>package.json</code>, lance <code>npm install</code>, puis applique les migrations.</p>',
|
|
7044
|
+
'<p>Votre projet est une application Next.js autonome sans dépôt amont à tirer : le nouveau code provient donc du paquet <code>create-nextblock</code> publié sur npm — exactement l''artefact à partir duquel votre projet a été généré, versionné en phase avec la release. NextBlock récupère votre version actuelle et la nouvelle, puis applique la différence entre les deux comme une <strong>fusion git à trois voies</strong> : la mise à jour se comporte donc exactement comme un <code>git pull</code> — les fichiers que vous n''avez jamais touchés se mettent à jour silencieusement, ceux que vous avez personnalisés conservent vos changements. Elle fusionne ensuite les nouvelles versions de dépendances dans votre <code>package.json</code>, lance <code>npm install</code> et applique les migrations.</p><p>Cela nécessite un dépôt git avec au moins un commit et une copie de travail propre — validez votre travail avant de mettre à jour. Sans cela il n''y a rien contre quoi fusionner : les fichiers sont alors copiés et tout ce qui est remplacé est conservé sous <code>.nextblock-backup/</code>.</p>'
|
|
7045
|
+
)
|
|
7046
|
+
)
|
|
7047
|
+
),
|
|
7048
|
+
updated_at = now()
|
|
7049
|
+
WHERE post_id = v_fr_post
|
|
7050
|
+
AND block_type = 'text';
|
|
7051
|
+
END IF;
|
|
7052
|
+
END
|
|
7053
|
+
$body$;
|
|
7054
|
+
|
|
7055
|
+
|
|
7056
|
+
-- >>> FROM: 00000000000022_updating_article_accuracy.sql <<<
|
|
7057
|
+
-- 00000000000022_updating_article_accuracy.sql
|
|
7058
|
+
-- Three accuracy fixes to the "How Updating NextBlock Works" article
|
|
7059
|
+
-- (seeded in 00000000000020, first corrected in 00000000000021).
|
|
7060
|
+
--
|
|
7061
|
+
-- 0. The merge is performed with \`git merge-file\`, not \`git apply --3way\`. The latter
|
|
7062
|
+
-- implies --index: it stages its result (so \`git diff\` shows the developer nothing),
|
|
7063
|
+
-- requires every path to be tracked (one gitignored framework path aborted the whole
|
|
7064
|
+
-- update), and requires the worktree to match the index. merge-file touches no git
|
|
7065
|
+
-- state at all. Consequently the resolution commands 021 shipped are wrong: there are
|
|
7066
|
+
-- no index stages, so \`git checkout --theirs/--ours\` does not apply. The conflict
|
|
7067
|
+
-- markers are ordinary text; \`git checkout -- <file>\` discards one file's merge.
|
|
7068
|
+
--
|
|
7069
|
+
-- 1. "A conflicted merge is aborted automatically" was true of only ONE path. The
|
|
7070
|
+
-- monorepo/fork path does abort and restore the tree, because the merge belongs to
|
|
7071
|
+
-- upstream. The standalone path deliberately LEAVES the conflict in the working tree,
|
|
7072
|
+
-- because it is the developer's own repository and resolving it is the whole point.
|
|
7073
|
+
-- The bullet now states both.
|
|
7074
|
+
-- 2. The Docker section claimed \`npm run update\` refreshes the schema. It does not, by
|
|
7075
|
+
-- design: the self-hosted stack ships its own migration runner (the \`migrate\` service
|
|
7076
|
+
-- in docker-compose.yml, which tracks applied versions in a different table), so the
|
|
7077
|
+
-- updater stages the SQL and hands off to \`npm run docker:up\` rather than applying it
|
|
7078
|
+
-- twice through two different trackers.
|
|
7079
|
+
--
|
|
7080
|
+
-- Same targeted, idempotent replace() approach as 021 — a no-op once the old sentence is
|
|
7081
|
+
-- gone. Data-only; no schema change.
|
|
7082
|
+
|
|
7083
|
+
DO $body$
|
|
7084
|
+
DECLARE
|
|
7085
|
+
v_en_post integer;
|
|
7086
|
+
v_fr_post integer;
|
|
7087
|
+
BEGIN
|
|
7088
|
+
SELECT id INTO v_en_post
|
|
7089
|
+
FROM public.posts WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
7090
|
+
ORDER BY id LIMIT 1;
|
|
7091
|
+
|
|
7092
|
+
SELECT id INTO v_fr_post
|
|
7093
|
+
FROM public.posts WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
7094
|
+
ORDER BY id LIMIT 1;
|
|
7095
|
+
|
|
7096
|
+
IF v_en_post IS NOT NULL THEN
|
|
7097
|
+
UPDATE public.blocks
|
|
7098
|
+
SET content = jsonb_set(
|
|
7099
|
+
content,
|
|
7100
|
+
'{html_content}',
|
|
7101
|
+
to_jsonb(
|
|
7102
|
+
replace(
|
|
7103
|
+
replace(
|
|
7104
|
+
replace(
|
|
7105
|
+
content->>'html_content',
|
|
7106
|
+
-- 021 shipped index-based resolution commands; the merge no longer
|
|
7107
|
+
-- uses the git index, so they do not apply.
|
|
7108
|
+
'<strong>your edit is kept</strong>. The update merges the upstream change into your version, and only a change that genuinely overlaps yours conflicts, with ordinary <code><<<<<<< ours</code> / <code>>>>>>>> theirs</code> markers. List them with <code>git diff --name-only --diff-filter=U</code> and resolve with <code>git checkout --theirs</code> or <code>--ours</code>.',
|
|
7109
|
+
'<strong>your edit is kept</strong>. The update merges the upstream change into your version, and only a change that genuinely overlaps yours conflicts — the updater lists those files, and each one carries ordinary <code><<<<<<< your version</code> / <code>>>>>>>> NextBlock</code> markers. Edit them as you would any conflict, or run <code>git checkout -- <file></code> to discard the merge for that one file.'
|
|
7110
|
+
),
|
|
7111
|
+
'<li><strong>A conflicted merge</strong> is aborted automatically — your working tree is left exactly as it was, with instructions printed for resolving it by hand.</li>',
|
|
7112
|
+
'<li><strong>A conflict</strong> behaves differently by install, on purpose. On a fork or clone the upstream merge is <em>aborted</em> and your working tree is left exactly as it was. On a standalone project the conflict is <em>left in place</em> for you to resolve — it is your own repository, and that is the point — and <code>git reset --hard HEAD</code> backs the whole update out.</li>'
|
|
7113
|
+
),
|
|
7114
|
+
'<p>The first command refreshes the application, its dependencies and the schema; the second rebuilds and restarts the containers. Your database and media live in Docker volumes and are never touched by either step — <code>docker:up</code> rebuilds images, not data.</p>',
|
|
7115
|
+
'<p>The first command updates the application and its dependencies and stages the new migrations; the second rebuilds the containers <em>and applies those migrations</em>. The self-hosted stack runs its own migration service, so the updater hands the schema step to it rather than applying the same SQL through two different trackers. Your database and media live in Docker volumes and are never touched by either command — <code>docker:up</code> rebuilds images, not data.</p>'
|
|
7116
|
+
)
|
|
7117
|
+
)
|
|
7118
|
+
),
|
|
7119
|
+
updated_at = now()
|
|
7120
|
+
WHERE post_id = v_en_post
|
|
7121
|
+
AND block_type = 'text';
|
|
7122
|
+
END IF;
|
|
7123
|
+
|
|
7124
|
+
IF v_fr_post IS NOT NULL THEN
|
|
7125
|
+
UPDATE public.blocks
|
|
7126
|
+
SET content = jsonb_set(
|
|
7127
|
+
content,
|
|
7128
|
+
'{html_content}',
|
|
7129
|
+
to_jsonb(
|
|
7130
|
+
replace(
|
|
7131
|
+
replace(
|
|
7132
|
+
replace(
|
|
7133
|
+
content->>'html_content',
|
|
7134
|
+
'<strong>votre modification est conservée</strong>. La mise à jour fusionne le changement amont dans votre version, et seul un changement qui chevauche réellement le vôtre entre en conflit, avec les marqueurs habituels <code><<<<<<< ours</code> / <code>>>>>>>> theirs</code>. Listez-les avec <code>git diff --name-only --diff-filter=U</code> et résolvez avec <code>git checkout --theirs</code> ou <code>--ours</code>.',
|
|
7135
|
+
'<strong>votre modification est conservée</strong>. La mise à jour fusionne le changement amont dans votre version, et seul un changement qui chevauche réellement le vôtre entre en conflit — la commande liste ces fichiers, et chacun porte les marqueurs habituels <code><<<<<<< your version</code> / <code>>>>>>>> NextBlock</code>. Modifiez-les comme n''importe quel conflit, ou lancez <code>git checkout -- <fichier></code> pour abandonner la fusion sur ce seul fichier.'
|
|
7136
|
+
),
|
|
7137
|
+
'<li><strong>Une fusion en conflit</strong> est annulée automatiquement — votre copie de travail reste intacte, avec les instructions pour résoudre à la main.</li>',
|
|
7138
|
+
'<li><strong>Un conflit</strong> se comporte différemment selon l''installation, volontairement. Sur un fork ou un clone, la fusion amont est <em>annulée</em> et votre copie de travail reste intacte. Sur un projet autonome, le conflit est <em>laissé en place</em> pour que vous le résolviez — c''est votre dépôt, et c''est tout l''intérêt — et <code>git reset --hard HEAD</code> annule toute la mise à jour.</li>'
|
|
7139
|
+
),
|
|
7140
|
+
'<p>La première commande met à jour l''application, ses dépendances et le schéma ; la seconde reconstruit et redémarre les conteneurs. Votre base de données et vos médias vivent dans des volumes Docker et ne sont touchés ni par l''une ni par l''autre — <code>docker:up</code> reconstruit des images, pas des données.</p>',
|
|
7141
|
+
'<p>La première commande met à jour l''application et ses dépendances et prépare les nouvelles migrations ; la seconde reconstruit les conteneurs <em>et applique ces migrations</em>. La pile auto-hébergée dispose de son propre service de migration : la mise à jour lui confie donc l''étape schéma plutôt que d''appliquer le même SQL via deux suivis différents. Votre base de données et vos médias vivent dans des volumes Docker et ne sont touchés par aucune des deux commandes — <code>docker:up</code> reconstruit des images, pas des données.</p>'
|
|
7142
|
+
)
|
|
7143
|
+
)
|
|
7144
|
+
),
|
|
7145
|
+
updated_at = now()
|
|
7146
|
+
WHERE post_id = v_fr_post
|
|
7147
|
+
AND block_type = 'text';
|
|
7148
|
+
END IF;
|
|
7149
|
+
END
|
|
7150
|
+
$body$;
|
|
7151
|
+
|
|
7152
|
+
|
|
7153
|
+
-- >>> FROM: 00000000000023_updating_article_layout_not_host.sql <<<
|
|
7154
|
+
-- 00000000000023_updating_article_layout_not_host.sql
|
|
7155
|
+
-- Corrects the most misleading claim in the "How Updating NextBlock Works" article
|
|
7156
|
+
-- (seeded 00000000000020, corrected in 021 and 022): that the automatic GitHub Action is
|
|
7157
|
+
-- about being deployed on Vercel.
|
|
7158
|
+
--
|
|
7159
|
+
-- It is not. The upstream-sync Action merges the NextBlock MONOREPO into the repository,
|
|
7160
|
+
-- so it only works where the repository IS the monorepo — a Vercel 1-click deploy, a
|
|
7161
|
+
-- GitHub fork, or a clone. A project scaffolded by \`npm create nextblock\` is the flattened
|
|
7162
|
+
-- standalone app (app/, components/, lib/ at the root); merging apps/ + libs/ + nx.json
|
|
7163
|
+
-- into it would wreck it. Pushing that project to GitHub and deploying it on Vercel does
|
|
7164
|
+
-- not change its layout, so it is still a \`npm run update\` install. Docker is orthogonal:
|
|
7165
|
+
-- it is how you RUN a project, not what shape the repository is.
|
|
7166
|
+
--
|
|
7167
|
+
-- Also documents that a merge conflict now holds the migration step back until the
|
|
7168
|
+
-- conflict is resolved, so the schema never moves ahead of undecided code.
|
|
7169
|
+
--
|
|
7170
|
+
-- Targeted, idempotent replace() as in 021/022. Data-only; no schema change.
|
|
7171
|
+
|
|
7172
|
+
DO $body$
|
|
7173
|
+
DECLARE
|
|
7174
|
+
v_en_post integer;
|
|
7175
|
+
v_fr_post integer;
|
|
7176
|
+
BEGIN
|
|
7177
|
+
SELECT id INTO v_en_post
|
|
7178
|
+
FROM public.posts WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
7179
|
+
ORDER BY id LIMIT 1;
|
|
7180
|
+
|
|
7181
|
+
SELECT id INTO v_fr_post
|
|
7182
|
+
FROM public.posts WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
7183
|
+
ORDER BY id LIMIT 1;
|
|
7184
|
+
|
|
7185
|
+
IF v_en_post IS NOT NULL THEN
|
|
7186
|
+
UPDATE public.blocks
|
|
7187
|
+
SET content = jsonb_set(
|
|
7188
|
+
content,
|
|
7189
|
+
'{html_content}',
|
|
7190
|
+
to_jsonb(
|
|
7191
|
+
replace(
|
|
7192
|
+
replace(
|
|
7193
|
+
replace(
|
|
7194
|
+
content->>'html_content',
|
|
7195
|
+
-- 1. The section intro: say what actually qualifies.
|
|
7196
|
+
'<p>This path updates itself. When you deployed, NextBlock created a repository you own; the dashboard’s <strong>Connect GitHub</strong> onboarding step installs a workflow into it that runs <strong>every day at midnight UTC</strong> and can also be triggered by hand from your repository’s <strong>Actions</strong> tab.</p>',
|
|
7197
|
+
'<p>This path updates itself. When you deployed, NextBlock created a repository you own; the dashboard’s <strong>Connect GitHub</strong> onboarding step installs a workflow into it that runs <strong>every day at midnight UTC</strong> and can also be triggered by hand from your repository’s <strong>Actions</strong> tab.</p>\\n<div class=''rounded-3xl border border-slate-200 bg-slate-50 p-6 my-8 dark:border-white/10 dark:bg-white/5''>\\n <p class=''mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-slate-600 dark:text-slate-300''>What qualifies — it is the repository, not the host</p>\\n <p class=''mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200''>The workflow merges the <strong>NextBlock monorepo</strong> into your repository, so it only works where your repository <em>is</em> that monorepo: a one-click deploy, a GitHub fork, or a clone. A project created with <code>npm create nextblock</code> is the flattened standalone app — <code>app/</code>, <code>components/</code> and <code>lib/</code> at the root — and merging <code>apps/</code>, <code>libs/</code> and <code>nx.json</code> into it would wreck it. Pushing that project to GitHub and deploying it on Vercel does not change its shape: it is still an <code>npm run update</code> install, and NextBlock will not offer it this workflow. Docker is a separate question entirely — that is how you <em>run</em> a project, not what shape its repository is.</p>\\n</div>'
|
|
7198
|
+
),
|
|
7199
|
+
-- 2. The FAQ answer, which asked exactly the question this clarifies.
|
|
7200
|
+
'<h3>I am on the one-click Vercel deploy — do I need to run anything?</h3>\\n<p>No. That path is fully automatic. The command exists for when you want an update <em>now</em> rather than at midnight, or when you are working on a local clone.</p>',
|
|
7201
|
+
'<h3>I am on the one-click Vercel deploy — do I need to run anything?</h3>\\n<p>No. That path is fully automatic. The command exists for when you want an update <em>now</em> rather than at midnight, or when you are working on a local clone.</p>\\n<h3>I deployed to Vercel, but from <code>npm create nextblock</code>. Is that automatic too?</h3>\\n<p>No — and this is the distinction that catches people out. Automatic updates depend on your repository being the NextBlock <strong>monorepo</strong>, not on where the site is hosted. A project scaffolded by the CLI is the flattened standalone app whatever you deploy it to, so it updates with <code>npm run update</code>. You will not see the <strong>Connect GitHub</strong> step on that kind of install, because the workflow it installs would merge a completely different source tree into yours.</p>'
|
|
7202
|
+
),
|
|
7203
|
+
-- 3. Conflicts hold the schema step.
|
|
7204
|
+
'<li><strong>A failed migration</strong> rolls back. Fix the cause and re-run; nothing half-applied is left behind.</li>',
|
|
7205
|
+
'<li><strong>A failed migration</strong> rolls back. Fix the cause and re-run; nothing half-applied is left behind.</li>\\n <li><strong>Unresolved conflicts hold the database back.</strong> If a merge left conflicts, the update finishes the code and dependency work but <em>stops before migrating</em> — your schema never moves ahead of code you have not finished deciding on. Resolve them and run <code>npm run update</code> again to apply the migrations, or walk away with <code>git reset --hard HEAD</code>; either way the database was never touched.</li>'
|
|
7206
|
+
)
|
|
7207
|
+
)
|
|
7208
|
+
),
|
|
7209
|
+
updated_at = now()
|
|
7210
|
+
WHERE post_id = v_en_post
|
|
7211
|
+
AND block_type = 'text';
|
|
7212
|
+
END IF;
|
|
7213
|
+
|
|
7214
|
+
IF v_fr_post IS NOT NULL THEN
|
|
7215
|
+
UPDATE public.blocks
|
|
7216
|
+
SET content = jsonb_set(
|
|
7217
|
+
content,
|
|
7218
|
+
'{html_content}',
|
|
7219
|
+
to_jsonb(
|
|
7220
|
+
replace(
|
|
7221
|
+
replace(
|
|
7222
|
+
replace(
|
|
7223
|
+
content->>'html_content',
|
|
7224
|
+
'<p>Ce chemin se met à jour tout seul. Lors du déploiement, NextBlock a créé un dépôt qui vous appartient ; l''étape <strong>Connect GitHub</strong> du tableau de bord y installe un workflow qui s''exécute <strong>chaque jour à minuit UTC</strong> et peut aussi être lancé à la demande depuis l''onglet <strong>Actions</strong> de votre dépôt.</p>',
|
|
7225
|
+
'<p>Ce chemin se met à jour tout seul. Lors du déploiement, NextBlock a créé un dépôt qui vous appartient ; l''étape <strong>Connect GitHub</strong> du tableau de bord y installe un workflow qui s''exécute <strong>chaque jour à minuit UTC</strong> et peut aussi être lancé à la demande depuis l''onglet <strong>Actions</strong> de votre dépôt.</p>\\n<div class=''rounded-3xl border border-slate-200 bg-slate-50 p-6 my-8 dark:border-white/10 dark:bg-white/5''>\\n <p class=''mt-0 text-xs font-semibold uppercase tracking-[0.22em] text-slate-600 dark:text-slate-300''>Ce qui compte : le dépôt, pas l''hébergeur</p>\\n <p class=''mt-3 mb-0 text-sm text-slate-700 dark:text-slate-200''>Le workflow fusionne le <strong>monorepo NextBlock</strong> dans votre dépôt : il ne fonctionne donc que si votre dépôt <em>est</em> ce monorepo — déploiement en un clic, fork GitHub ou clone. Un projet créé avec <code>npm create nextblock</code> est l''application autonome aplatie — <code>app/</code>, <code>components/</code> et <code>lib/</code> à la racine — et y fusionner <code>apps/</code>, <code>libs/</code> et <code>nx.json</code> le casserait. Pousser ce projet sur GitHub et le déployer sur Vercel ne change pas sa forme : il se met toujours à jour avec <code>npm run update</code>, et NextBlock ne lui proposera pas ce workflow. Docker est une tout autre question — c''est la façon d''<em>exécuter</em> un projet, pas la forme de son dépôt.</p>\\n</div>'
|
|
7226
|
+
),
|
|
7227
|
+
'<h3>Je suis sur le déploiement Vercel en un clic — dois-je lancer quelque chose ?</h3>\\n<p>Non. Ce chemin est entièrement automatique. La commande existe pour mettre à jour <em>tout de suite</em> plutôt qu''à minuit, ou lorsque vous travaillez sur un clone local.</p>',
|
|
7228
|
+
'<h3>Je suis sur le déploiement Vercel en un clic — dois-je lancer quelque chose ?</h3>\\n<p>Non. Ce chemin est entièrement automatique. La commande existe pour mettre à jour <em>tout de suite</em> plutôt qu''à minuit, ou lorsque vous travaillez sur un clone local.</p>\\n<h3>J''ai déployé sur Vercel, mais depuis <code>npm create nextblock</code>. Est-ce automatique aussi ?</h3>\\n<p>Non — et c''est la distinction qui piège le plus. Les mises à jour automatiques dépendent du fait que votre dépôt soit le <strong>monorepo</strong> NextBlock, pas de l''endroit où le site est hébergé. Un projet généré par le CLI reste l''application autonome aplatie, quel que soit l''hébergeur : il se met à jour avec <code>npm run update</code>. L''étape <strong>Connect GitHub</strong> ne s''affiche pas sur ce type d''installation, car le workflow qu''elle installe fusionnerait une arborescence totalement différente dans la vôtre.</p>'
|
|
7229
|
+
),
|
|
7230
|
+
'<li><strong>Une migration en échec</strong> est annulée. Corrigez la cause et relancez : rien ne reste à moitié appliqué.</li>',
|
|
7231
|
+
'<li><strong>Une migration en échec</strong> est annulée. Corrigez la cause et relancez : rien ne reste à moitié appliqué.</li>\\n <li><strong>Les conflits non résolus bloquent la base.</strong> Si une fusion a laissé des conflits, la mise à jour termine le code et les dépendances mais <em>s''arrête avant les migrations</em> — votre schéma ne prend jamais de l''avance sur un code que vous n''avez pas fini d''arbitrer. Résolvez-les puis relancez <code>npm run update</code> pour appliquer les migrations, ou abandonnez avec <code>git reset --hard HEAD</code> : dans les deux cas la base n''a jamais été touchée.</li>'
|
|
7232
|
+
)
|
|
7233
|
+
)
|
|
7234
|
+
),
|
|
7235
|
+
updated_at = now()
|
|
7236
|
+
WHERE post_id = v_fr_post
|
|
7237
|
+
AND block_type = 'text';
|
|
7238
|
+
END IF;
|
|
7239
|
+
END
|
|
7240
|
+
$body$;
|
|
7241
|
+
|
|
7242
|
+
|
|
7243
|
+
-- >>> FROM: 00000000000024_updating_article_newline_fix.sql <<<
|
|
7244
|
+
-- 00000000000024_updating_article_newline_fix.sql
|
|
7245
|
+
-- Repairs two mistakes made by 00000000000023 in the "How Updating NextBlock Works"
|
|
7246
|
+
-- article, and lands the FAQ entry that migration failed to insert.
|
|
7247
|
+
--
|
|
7248
|
+
-- 1. RENDERING BUG. 023 wrote \`\\n\` inside ordinary single-quoted SQL literals. With
|
|
7249
|
+
-- standard_conforming_strings on (the default), that is a literal backslash followed
|
|
7250
|
+
-- by 'n' — not a newline — so five visible "\\n" sequences were stored in the article
|
|
7251
|
+
-- body. Replaced here with real newlines via chr(10). Idempotent: once none remain,
|
|
7252
|
+
-- replace() is a no-op.
|
|
7253
|
+
--
|
|
7254
|
+
-- 2. SILENT NO-MATCH. 023's FAQ replacement targeted a string spanning \`</h3>\\n<p>\`, and
|
|
7255
|
+
-- for the same reason the literal never matched the real newline in the stored HTML, so
|
|
7256
|
+
-- the replacement quietly did nothing. Redone here by anchoring on the single-line <h3>
|
|
7257
|
+
-- alone and prepending the new entry — no newline in either the search or the
|
|
7258
|
+
-- replacement, which is the rule this file establishes for editing the article.
|
|
7259
|
+
--
|
|
7260
|
+
-- Data-only; no schema change.
|
|
7261
|
+
|
|
7262
|
+
DO $body$
|
|
7263
|
+
DECLARE
|
|
7264
|
+
v_en_post integer;
|
|
7265
|
+
v_fr_post integer;
|
|
7266
|
+
BEGIN
|
|
7267
|
+
SELECT id INTO v_en_post
|
|
7268
|
+
FROM public.posts WHERE language_id = 1 AND slug = 'how-updating-works'
|
|
7269
|
+
ORDER BY id LIMIT 1;
|
|
7270
|
+
|
|
7271
|
+
SELECT id INTO v_fr_post
|
|
7272
|
+
FROM public.posts WHERE language_id = 2 AND slug = 'comment-fonctionnent-les-mises-a-jour'
|
|
7273
|
+
ORDER BY id LIMIT 1;
|
|
7274
|
+
|
|
7275
|
+
IF v_en_post IS NOT NULL THEN
|
|
7276
|
+
UPDATE public.blocks
|
|
7277
|
+
SET content = jsonb_set(
|
|
7278
|
+
content,
|
|
7279
|
+
'{html_content}',
|
|
7280
|
+
to_jsonb(
|
|
7281
|
+
replace(
|
|
7282
|
+
-- (1) literal backslash-n -> real newline
|
|
7283
|
+
replace(content->>'html_content', E'\\\\n', chr(10)),
|
|
7284
|
+
-- (2) the FAQ entry 023 failed to insert
|
|
7285
|
+
'<h3>I am on the one-click Vercel deploy — do I need to run anything?</h3>',
|
|
7286
|
+
'<h3>I deployed to Vercel, but from <code>npm create nextblock</code>. Is that automatic too?</h3><p>No — and this is the distinction that catches people out. Automatic updates depend on your repository being the NextBlock <strong>monorepo</strong>, not on where the site is hosted. A project scaffolded by the CLI is the flattened standalone app whatever you deploy it to, so it updates with <code>npm run update</code>. You will not see the <strong>Connect GitHub</strong> step on that kind of install, because the workflow it installs would merge a completely different source tree into yours.</p><h3>I am on the one-click Vercel deploy — do I need to run anything?</h3>'
|
|
7287
|
+
)
|
|
7288
|
+
)
|
|
7289
|
+
),
|
|
7290
|
+
updated_at = now()
|
|
7291
|
+
WHERE post_id = v_en_post
|
|
7292
|
+
AND block_type = 'text';
|
|
7293
|
+
END IF;
|
|
7294
|
+
|
|
7295
|
+
IF v_fr_post IS NOT NULL THEN
|
|
7296
|
+
UPDATE public.blocks
|
|
7297
|
+
SET content = jsonb_set(
|
|
7298
|
+
content,
|
|
7299
|
+
'{html_content}',
|
|
7300
|
+
to_jsonb(
|
|
7301
|
+
replace(
|
|
7302
|
+
replace(content->>'html_content', E'\\\\n', chr(10)),
|
|
7303
|
+
'<h3>Je suis sur le déploiement Vercel en un clic — dois-je lancer quelque chose ?</h3>',
|
|
7304
|
+
'<h3>J''ai déployé sur Vercel, mais depuis <code>npm create nextblock</code>. Est-ce automatique aussi ?</h3><p>Non — et c''est la distinction qui piège le plus. Les mises à jour automatiques dépendent du fait que votre dépôt soit le <strong>monorepo</strong> NextBlock, pas de l''endroit où le site est hébergé. Un projet généré par le CLI reste l''application autonome aplatie, quel que soit l''hébergeur : il se met à jour avec <code>npm run update</code>. L''étape <strong>Connect GitHub</strong> ne s''affiche pas sur ce type d''installation, car le workflow qu''elle installe fusionnerait une arborescence totalement différente dans la vôtre.</p><h3>Je suis sur le déploiement Vercel en un clic — dois-je lancer quelque chose ?</h3>'
|
|
7305
|
+
)
|
|
7306
|
+
)
|
|
7307
|
+
),
|
|
7308
|
+
updated_at = now()
|
|
7309
|
+
WHERE post_id = v_fr_post
|
|
7310
|
+
AND block_type = 'text';
|
|
7311
|
+
END IF;
|
|
7312
|
+
END
|
|
7313
|
+
$body$;
|
|
7314
|
+
|
|
7315
|
+
|
|
6797
7316
|
-- Step D: Record the applied migrations in history (truncated in Step B) so
|
|
6798
7317
|
-- \`npm run db:migrate:check\` reports up to date instead of listing every file as pending.
|
|
6799
7318
|
INSERT INTO supabase_migrations.schema_migrations (version, name) VALUES
|
|
@@ -6816,7 +7335,12 @@ CREATE POLICY "Admins insert site script revisions" ON public.site_script_revisi
|
|
|
6816
7335
|
('00000000000016', 'product_revisions_and_revision_baseline'),
|
|
6817
7336
|
('00000000000017', 'cortex_ai_mcp_server'),
|
|
6818
7337
|
('00000000000018', 'site_scripts'),
|
|
6819
|
-
('00000000000019', 'site_script_revisions')
|
|
7338
|
+
('00000000000019', 'site_script_revisions'),
|
|
7339
|
+
('00000000000020', 'updating_article'),
|
|
7340
|
+
('00000000000021', 'updating_article_git_merge'),
|
|
7341
|
+
('00000000000022', 'updating_article_accuracy'),
|
|
7342
|
+
('00000000000023', 'updating_article_layout_not_host'),
|
|
7343
|
+
('00000000000024', 'updating_article_newline_fix')
|
|
6820
7344
|
ON CONFLICT (version) DO NOTHING;
|
|
6821
7345
|
|
|
6822
7346
|
-- Step E: Anchor preserved profiles
|