Updating your deployment
A deployment does not update itself. You pull the new code into your repository and deploy it. Your data stays in your D1 database. Your secrets and dashboard variables stay in your Cloudflare account.
What a deploy does
Section titled “What a deploy does”pnpm run deploy runs two commands in this order:
wrangler d1 migrations apply DB --remotechanges the database.wrangler deployuploads the new code.
The migrations run before the code. If a migration fails, the second command does not run, and the old code keeps running. A migration that succeeded stays applied.
A plain wrangler deploy skips the migrations. Do not use it for an update.
If you used the deploy button
Section titled “If you used the deploy button”If you deployed before the vars block was removed, read
the section on earlier deployments before
you merge.
Cloudflare created a new repository in your GitHub or GitLab account and connected it to your Worker. The repository has no automatic link to the slotmirror repository. You add the link yourself.
-
In a clone of your repository, add the slotmirror repository as a remote:
Terminal window git remote add upstream https://github.com/slotmirror/slotmirrorgit fetch upstream -
Merge the new code into your branch and push it:
Terminal window git merge upstream/maingit pushIf you changed files, for example
wrangler.jsonc, Git can report a conflict. Resolve it before you push. Keep your owndatabase_idanddatabase_name. -
In the dashboard, open Workers & Pages, your Worker, Settings, Builds. Check that the build is connected to your repository. Enter
pnpm run deployas the deploy command, because that command runs the migrations. The commandnpx wrangler deploydoes not. -
If a push does not start a build, deploy from a clone as shown below.
If you cloned the repository
Section titled “If you cloned the repository”If you deployed before the vars block was removed, read
the section on earlier deployments before
you deploy.
cd slotmirrorgit pullpnpm install --frozen-lockfilepnpm run deployRun pnpm wrangler login first if your session expired. pnpm run deploy needs your own
database_id in wrangler.jsonc. If git pull reports a conflict on that file, keep your
database_id.
If you deployed before the vars block was removed
Section titled “If you deployed before the vars block was removed”An earlier wrangler.jsonc had a vars block. It listed ORG_NAME, ALLOWED_EMAILS,
ALLOWED_DOMAINS, ALLOWED_TENANT_IDS, ADMIN_EMAILS, PRIVACY_CONTACT, SIGN_IN_PROVIDERS,
PUBLIC_URL, DATA_JURISDICTION, MAX_DETAIL_TO_EXTERNAL, MAX_DETAIL_FROM_EXTERNAL and
TIME_ZONE. Each deploy replaced the dashboard value of every name in that block. This included a
name with an empty value.
Now wrangler.jsonc has no vars block and sets keep_vars. A deploy keeps the dashboard values
that the file does not name. Without keep_vars, a deploy removes dashboard variables, and it
overwrites the variables that the file lists. Set your values in the dashboard before you update.
- Write down your values. Read them from the
varsblock in yourwrangler.jsonc, or from Variables and Secrets in the dashboard. A deploy from the old file may have replaced a dashboard value with an empty one. If a value is missing in the dashboard, enter it again. - In Variables and Secrets, add each value as a Text variable with the same name. Do this before you deploy the new version.
- Update as described above. If the merge conflicts on the
varsblock, take the new file and remove the block. Keep your owndatabase_idanddatabase_name. - Open your Worker. Check the values you rely on, for example who can sign in.
Take care of these two values:
DATA_JURISDICTION: if its value changes for existing data, every account disconnects. Set the same value as before. See Settings.TIME_ZONE: the old file setUTC. If you did not set another zone, no action is needed. The default isUTC.
This page does not state what Cloudflare does with a value that an earlier deploy set from the file and that the dashboard does not hold. Do not rely on it. Set the value in the dashboard.
If you want a value in the file again, add a vars entry. Then use the file for that name and not
the dashboard. The file value replaces the dashboard value on every deploy.
All-day events are mirrored by default
Section titled “All-day events are mirrored by default”New rules now mirror all-day events, unless the events are marked as free. Rules created on the Rules page
keep their behavior, because each rule stores skipAllDay in rules.options. The Skip all-day
events switch stays on for a user with a rule that skips these events, and that user’s new rules
skip them too. A save changes the rules only if the user changes this switch. Then every rule of
the user follows it.
If such a user never saved the settings and removes their last rule, the switch goes off. Turn it on again before you add a rule, or the new rule mirrors all-day events.
A rule without skipAllDay in rules.options starts to mirror all-day events after the update. The
The Rules page never writes such a rule. It can come from your own SQL, because options defaults to {}.
To keep the old behavior, add "skipAllDay": true to the row before you update.
All-day blocks in Outlook now lie in the time zone of the mailbox, if Microsoft Graph names that zone. slotmirror reads the zone once per day from the working hours of the mailbox, and this needs no new permission. If the mailbox names no usable zone, the blocks use UTC as before. If the read fails, the blocks keep the last known zone, or use UTC if no zone is known. slotmirror reads the zone again after 15 minutes.
Two other cases also use UTC:
- If Graph refuses an all-day write with status 400, and no other all-day write of the same batch passes, the blocks use UTC for the day.
- If a sync step has too few requests left for the read, its blocks use the last known zone, or UTC if no zone is known.
The Graph documentation says that getSchedule, the call behind this read, does not support
personal Microsoft accounts. So all-day blocks on personal accounts probably stay in UTC. We did not
test this on a live personal account.
Existing blocks stay as they are, and a block written in UTC also stays that way. Such an all-day block stays off the local day, by one hour at CET and by eight hours at Pacific time, until its content changes.
The new interface and its addresses
Section titled “The new interface and its addresses”This release replaces the interface. Read this section before you update.
- New addresses. The pages now live at
/(Overview, and the sign-in when you are signed out),/mirroring,/calendars,/activity,/adminand/tokens. The page/tokensexists only whenMCP_ENABLED=1. - Redirects for one release. The address
/rulesanswers with a 301 redirect to/mirroring, and/admin/activityanswers with a 308 redirect to the activity of the whole organisation on/activity. These redirects stay for one release only. Update bookmarks and links that point to the old addresses. The sign-in, the OAuth flow, the MCP endpoint, the webhooks and the form endpoints keep their addresses. - Migration 0025. It adds the column
oauth_codes.scope. It runs with the usual migrate step ofpnpm run deploy, before the new Worker starts. The change is additive: the previous Worker runs on the new schema. - Assets are built. The deploy step now builds the static files into
dist/public, with the content hash in each file name.wrangler deployruns this build through thebuildcommand inwrangler.jsonc, so no extra step is needed.
After the update
Section titled “After the update”Open your Worker and sign in. If a checklist shows instead of the sign-in page, a variable or secret is missing. The checklist names it. See the settings reference.
Going back to an older version
Section titled “Going back to an older version”Migrations do not run backward. After an update, the database keeps the new tables and columns, also when you deploy older code.
- Clone your repository to your computer and run
pnpm install. If you used the deploy button, you need this step, because the build in the dashboard cannot deploy an older version for you. Check out the commit or tag of the older version. - Run
pnpm wrangler deploy. The older foldermigrations/holds only migrations that already ran, so no migration is needed. - Open your Worker and check that sign-in and sync work.
If the older version is from before the vars block was removed, its wrangler.jsonc lists the
vars block again. That deploy overwrites the dashboard values of every name in the block, also
with an empty value. Write down your values first, and set them again after the deploy.
The older code runs on the newer database. This works only if the migrations between the two versions add tables or columns and remove nothing. All migrations up to now do this. A later migration can differ. Before you go back across versions, read the changelog for every version in between.
Before an update, you can export a copy of your D1 database:
pnpm wrangler d1 export <database_name> --remote --output backup.sqlUse the database_name from your wrangler.jsonc. The default is slotmirror.
The file holds sign-in addresses and calendar names. Store it with care. It does not include the state of the Durable Objects, where each connected account keeps its tokens and its mappings.