Upgrade: 0.1.0-beta.31
StudioCMS 0.1.0-beta.31 introduces significant changes, including a new Kysely based database layer, a revamped plugin system, and various new features and improvements. This guide will help you upgrade your existing StudioCMS project to the latest version.
Breaking changes
Section titled “Breaking changes”- Refactored Plugin System. Please see the Plugin docs for more details.
- Implemented new Kysely based database layer.
- Removed support for config options directly passed to the StudioCMS astro integration, now all config options must be defined in
studiocms.config.mjsfile. Please see the Config Reference for more details.
New Features
Section titled “New Features”- Implemented new
studiocms migratecommand to handle database migrations. - Allow disabling Generator meta tags via
features.dashboard.security.hideGeneratorTagsconfig option. - StudioCMS now supports different database dialects via Kysely^.
- Introduced new middleware to display system errors on pages with errors instead of crashing the entire site.
- New plugin features:
- Dynamic components and scripts injection to the dashboard via new plugin hooks.
- New db helpers for easier database access within plugins.
- Introduced new Dashboard page for managing the System management.
- Includes a System info (debug) panel
- Provides quick access to your database tables while in production.
- Added the new developer toolbar app built-in to StudioCMS for viewing and managing your database while in development mode.
- Integrated optional web-vitals/analytics tracking into the dashboard for better performance insights.
- This can be enabled via the
features.webVitalsconfig option. - For those who previously used the
@studiocms/web-vitalsor@astrojs/web-vitalsintegrations, this is now built-in and can be configured via the StudioCMS config.
- This can be enabled via the
Bug Fixes & Improvements
Section titled “Bug Fixes & Improvements”- Updated ghost user image url.
- Refactored page data
urlRoutegeneration to resolve correctly. - Refactored and simplified dashboard layout components.
- Improved StudioCMS config types and JSDoc comments.
- Refactored CLI commands to use new database layer.
- Introduced new debug utilities for easier access to helpful debug information.
Migration Steps
Section titled “Migration Steps”To upgrade your StudioCMS project to version 0.1.0-beta.31, please follow these steps:
-
Update your StudioCMS dependencies to the latest version:
Terminal window npx @studiocms/upgradeTerminal window pnpx @studiocms/upgradeTerminal window yarn dlx @studiocms/upgrade -
If you have custom plugins, ensure they are updated to be compatible with the new plugin system. Refer to the Plugin docs for guidance.
-
Review your
studiocms.config.mjsfile to ensure all configuration options are correctly set according to the new schema. Refer to the Config Reference for details.-
Previously used
@studiocms/web-vitalsor@astrojs/web-vitalsintegrations? Remove them from your project dependencies and configure the built-in web vitals tracking via thefeatures.webVitalsoption in yourstudiocms.config.mjsfile:studiocms.config.mjs export default defineStudioCMSConfig({features: {webVitals: true,},});
-
-
Setup a new database connection for the new Kysely based database layer. Update your
.envfile with the necessary database connection details. Keep your previous database intact for migration.Refer to the Database Setup Guide for more information on configuring your database.Refer to the Environment Variables Docs for more information on configuring your environment variables. -
Configure your database dialect in
studiocms.config.mjsunder thedboption. For example, to use libSQL:studiocms.config.mjs export default defineStudioCMSConfig({db: {dialect: 'libsql', // or 'postgresql', 'mysql'},});StudioCMS now supports multiple database dialects via Kysely. Ensure you select the correct dialect for your database. By default if no dialect is specified it will use
libsql. -
Install the necessary database client packages for your chosen database dialect:
Terminal window npm i @libsql/client @libsql/kysely-libsqlTerminal window pnpm add @libsql/client @libsql/kysely-libsqlTerminal window yarn add @libsql/client @libsql/kysely-libsqlTerminal window npm i mysql2Terminal window pnpm add mysql2Terminal window yarn add mysql2 -
Download the migration tool into the root of your StudioCMS project:
Terminal window npm i @studiocms/migratorTerminal window pnpm add @studiocms/migratorTerminal window yarn add @studiocms/migratorThis tool will read your
studiocms.config.mjsfile to be able to connect to the correct database dialect. -
Running Schema Migrations:
Since the database layer has changed, you will need to run migrations to update your database schema to be compatible with the new version. There is two ways to do this:
Built into the StudioCMS CLI is a new
migratecommand that will run the necessary migrations for you. To use it, run the following command in your project directory:Terminal window npx studiocms migrateTerminal window pnpm studiocms migrateTerminal window yarn studiocms migrateYou will be prompted to select an option to, migrate your database schema to the latest version, rollback to a previous version, or view the current migration status. Select “Migrate to Latest” to update your database schema.
You can always check the status of your migrations by running
studiocms migrate --statusto see which migrations have been applied and which are pending.You can also use
--latestor-lflag to automatically migrate to the latest version without prompts. or use--rollbackor-rto rollback to a single version.Alternatively, you can use the migration tool you installed in previous step. To do this, continue to the next step, and use the Web UI to run the migrations.
-
Run the Migration Tool Web UI:
Start the migration tool by running the following command in your project directory:
Terminal window npx studiocms-migratorTerminal window pnpm studiocms-migratorTerminal window yarn studiocms-migratorThis will start a local web server. Open your browser and navigate to
http://localhost:4321to access the migration tool interface.This interface will give you options to migrate your database schema, as well as migrating your data from your old database to the new one.
-
Once the migration is complete, start your StudioCMS project as usual:
Terminal window npm run devTerminal window pnpm run devTerminal window yarn run devYour project should now be running with the updated database schema and configuration.
Final Notes
Section titled “Final Notes”- Ensure you have backups of your database before performing migrations.
- Test your application thoroughly after the migration to catch any issues early.
- Refer to the StudioCMS documentation for more information on new features and changes.
- If you encounter any issues during the migration process, please reach out on our Discord community^, or open an issue on our GitHub repository^.