Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: upgrade upgrade duration estimations, detection of legacy auth roles and dependent objects which might be dropped, light mode and timezone fixes (#18411)

Paul Cioancaf16a311a4c34
diff --git a/apps/docs/pages/guides/platform/migrating-and-upgrading-projects.mdx b/apps/docs/pages/guides/platform/migrating-and-upgrading-projects.mdx
index 6b223abad65..603a5b0ee1b 100644
--- a/apps/docs/pages/guides/platform/migrating-and-upgrading-projects.mdx
+++ b/apps/docs/pages/guides/platform/migrating-and-upgrading-projects.mdx
@@ -62,6 +62,55 @@ Breaking changes are generally only present in major version upgrades of Postgre
If you are upgrading from a significantly older version, you will need to consider the release notes for any intermediary releases as well.
+#### Objects dependent on Postgres extensions
+
+pg_upgrade does not support upgrading of databases containing reg\* data types referencing system OIDs.
+If you have created any objects that depend on the following extensions, you will need to recreate them after the upgrade.
+
+Extensions registering system OID-specific reg\* data types:
+
+- `plv8`
+- `plcoffee`
+- `plls`
+
+As these extensions offer support to create functions in different languages, you will only need to check for functions using the languages enabled by the above extensions.
+Any objects depending on the detected objects (e.g. triggers, views, tables, etc.) will need to be modified to exclude references to them.
+
+The following query returns the function name and their definitions, to help in recreating them post-upgrade.
+
+```sql
+SELECT
+ pn.nspname || '.' || objid::regproc AS function_name,
+ pg_get_functiondef(objid) || ';' AS function_definition
+FROM pg_depend d
+ JOIN pg_language l on (d.refobjid = l.oid)
+ JOIN pg_proc pp on (d.objid = pp.oid)
+ JOIN pg_namespace pn on (pp.pronamespace = pn.oid)
+WHERE l.lanname in ('plls', 'plcoffee', 'plv8')
+ AND pn.nspname <> 'pg_catalog';
+```
+
+#### Authentication method changes - deprecating md5 in favor of scram-sha-256
+
+The md5 hashing method has [known weaknesses](https://en.wikipedia.org/wiki/MD5#Security) that make it unsuitable for cryptography.
+As such, we are deprecating md5 in favor of [scram-sha-256](https://www.postgresql.org/docs/current/auth-password.html), which is the default and most secure authentication method used in the latest Postgres versions.
+
+We automatically migrate Supabase-managed roles' passwords to scram-sha-256 during the upgrade process, but you will need to manually migrate the passwords of any custom roles you have created, else you won't be able to connect using them after the upgrade.
+
+To identify roles using the md5 hashing method and migrate their passwords, you can use the following SQL statements after the upgrade:
+
+```sql
+-- List roles using md5 hashing method
+SELECT
+ rolname
+FROM pg_authid
+WHERE rolcanlogin = true
+ AND rolpassword LIKE 'md5%';
+
+-- Migrate a role's password to scram-sha-256
+ALTER ROLE <role_name> WITH PASSWORD '<password>';
+```
+
#### Post-upgrade validation
Supabase performs extensive pre- and post-upgrade validations to ensure that the database has been correctly upgraded. However, you should plan for your own application-level validations, as there might be changes you might not have anticipated, and this should be budgeted for when planning your downtime window.
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.constants.ts b/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.constants.ts
index e36276103e7..69b0f3dd579 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.constants.ts
+++ b/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.constants.ts
@@ -2,7 +2,7 @@
export const BREAKING_CHANGES = {
'postgrest-v10': {
- title: 'Postgrest will be upgraded to V10',
+ title: 'Postgrest will be upgraded to v11',
url: 'https://postgrest.org/en/stable/releases/v10.0.0.html#breaking-changes',
},
}
@@ -12,8 +12,4 @@ export const MANUAL_INTERVENTIONS = {
title: 'Project is too old',
description: '',
},
- project_kps_enabled: {
- title: 'Project has KPS enabled',
- description: '',
- },
}
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.tsx b/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.tsx
index 75730c83b2d..a58625d5b09 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.tsx
+++ b/studio/components/interfaces/Settings/General/Infrastructure/ProjectUpgradeAlert/ProjectUpgradeAlert.tsx
@@ -3,24 +3,23 @@ import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
import {
- Alert,
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
+ Alert_Shadcn_,
Button,
Form,
IconAlertCircle,
- IconExternalLink,
- IconPackage,
+ IconAlertTriangle,
Listbox,
Modal,
} from 'ui'
import { useParams } from 'common/hooks'
-import InformationBox from 'components/ui/InformationBox'
import { useProjectUpgradeEligibilityQuery } from 'data/config/project-upgrade-eligibility-query'
import { useProjectUpgradeMutation } from 'data/projects/project-upgrade-mutation'
import { setProjectStatus } from 'data/projects/projects-query'
import { useStore } from 'hooks'
import { PROJECT_STATUS } from 'lib/constants'
-import { BREAKING_CHANGES } from './ProjectUpgradeAlert.constants'
const ProjectUpgradeAlert = () => {
const router = useRouter()
@@ -34,6 +33,9 @@ const ProjectUpgradeAlert = () => {
const currentPgVersion = (data?.current_app_version ?? '').split('supabase-postgres-')[1]
const latestPgVersion = (data?.latest_app_version ?? '').split('supabase-postgres-')[1]
+ const durationEstimateHours = data?.duration_estimate_hours || 1
+ const legacyAuthCustomRoles = data?.legacy_auth_custom_roles || []
+
const initialValues = { version: data?.target_upgrade_versions?.[0]?.postgres_version ?? 0 }
const { mutate: upgradeProject, isLoading: isUpgrading } = useProjectUpgradeMutation({
onSuccess: (res, variables) => {
@@ -50,18 +52,19 @@ const ProjectUpgradeAlert = () => {
return (
<>
- <Alert
- icon={<IconPackage className="text-brand" strokeWidth={1.5} />}
- variant="success"
- title="Your project can be upgraded to the latest version of Postgres"
- >
- <p className="mb-3">
- The latest version of Postgres ({latestPgVersion}) is available for your project.
- </p>
- <Button size="tiny" type="primary" onClick={() => setShowUpgradeModal(true)}>
- Upgrade project
- </Button>
- </Alert>
+ <Alert_Shadcn_ title="Your project can be upgraded to the latest version of Postgres">
+ <AlertTitle_Shadcn_>
+ Your project can be upgraded to the latest version of Postgres
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <p className="mb-3">
+ The latest version of Postgres ({latestPgVersion}) is available for your project.
+ </p>
+ <Button size="tiny" type="primary" onClick={() => setShowUpgradeModal(true)}>
+ Upgrade project
+ </Button>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
<Modal
hideFooter
visible={showUpgradeModal}
@@ -79,48 +82,92 @@ const ProjectUpgradeAlert = () => {
<div className="py-6">
<Modal.Content>
<div className="space-y-4">
+ <p className="text-sm">All services are going offline.</p>
<p className="text-sm">
- All services, including Auth, Rest, and Extensions will be upgraded. This
- action cannot be undone.
+ You will not be able to downgrade back to Postgres {currentPgVersion}.
</p>
+ <Alert_Shadcn_ title="Your project will be offline while the upgrade is in progress">
+ <IconAlertCircle className="h-4 w-4" strokeWidth={2} />
+ <AlertTitle_Shadcn_>
+ Your project will be offline for up to {durationEstimateHours} hour
+ {durationEstimateHours === 1 ? '' : 's'}
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <p>
+ It is advised to upgrade at a time when there will be minimal impact for
+ your application.
+ </p>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
{(data?.potential_breaking_changes ?? []).length > 0 && (
- <InformationBox
- icon={<IconAlertCircle strokeWidth={2} />}
- title="There will be breaking changes involved with the upgrade"
- description={
- <ul className="list-disc pl-4">
- {data?.potential_breaking_changes.map((reason) => {
- const change = (BREAKING_CHANGES as any)[reason]
- if (change !== undefined)
- return (
- <li key={reason}>
- <p className="text-foreground">{change.title}</p>
- <p className="flex items-center space-x-1">
- <span>This update has breaking changes. Read more </span>
- <Link href={change.url}>
- <a className="text-brand opacity-90 flex items-center space-x-1">
- <span>here</span>
- <IconExternalLink size="tiny" strokeWidth={2} />
- </a>
- </Link>
- </p>
- </li>
- )
- else return null
- })}
- </ul>
- }
- />
+ <Alert_Shadcn_ variant="destructive" title="Breaking changes">
+ <IconAlertCircle className="h-4 w-4" strokeWidth={2} />
+ <AlertTitle_Shadcn_>Breaking changes</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex flex-col gap-3">
+ <p>
+ Your project will be upgraded across major versions of Postgres. This
+ may involve breaking changes.
+ </p>
+
+ <div>
+ <Link
+ href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#caveats"
+ passHref
+ >
+ <Button size="tiny" type="default" asChild>
+ <a target="_blank" rel="noreferrer">
+ View docs
+ </a>
+ </Button>
+ </Link>
+ </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
+ {legacyAuthCustomRoles.length > 0 && (
+ <Alert_Shadcn_
+ variant="warning"
+ title="Custom Postgres roles using md5 authentication have been detected"
+ >
+ <IconAlertTriangle className="h-4 w-4" strokeWidth={2} />
+ <AlertTitle_Shadcn_>
+ Custom Postgres roles will not work automatically after upgrade
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex flex-col gap-3">
+ <p>You must run a series of commands after upgrading.</p>
+ <p>
+ This is because new Postgres versions use scram-sha-256 authentication
+ by default and do not support md5, as it has been deprecated.
+ </p>
+ <div>
+ <p className="mb-1">Run the following commands after the upgrade:</p>
+ <div className="flex items-baseline gap-2">
+ <code className="text-xs">
+ {legacyAuthCustomRoles.map((role) => (
+ <div key={role} className="pb-1">
+ ALTER ROLE <span className="text-brand">{role}</span> WITH
+ ENCRYPTED PASSWORD '
+ <span className="text-brand">newpassword</span>';
+ </div>
+ ))}
+ </code>
+ </div>
+ </div>
+ <div>
+ <Link
+ href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#caveats"
+ passHref
+ >
+ <Button size="tiny" type="default" asChild>
+ <a target="_blank" rel="noreferrer">
+ View docs
+ </a>
+ </Button>
+ </Link>
+ </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
)}
- <Alert
- withIcon
- variant="warning"
- title="Your project will be offline while the upgrade is in progress"
- >
- Upgrades will take a few minutes depending on the size of your database. It
- is advised to upgrade at a time when there will be minimal impact for your
- application
- </Alert>
<Listbox
id="version"
name="version"
diff --git a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
index 83f32fa9afe..070d979d2c2 100644
--- a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
+++ b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx
@@ -107,7 +107,7 @@ const RestartServerButton = () => {
</Button>
{canRestartProject && isProjectActive && (
<DropdownMenu>
- <DropdownMenuTrigger>
+ <DropdownMenuTrigger asChild>
<Button
type="default"
className="rounded-l-none px-[4px] py-[5px]"
diff --git a/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx b/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx
index 0961a4c0ef2..dc10659ab6e 100644
--- a/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx
+++ b/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx
@@ -14,7 +14,14 @@ import AlertError from 'components/ui/AlertError'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useProjectUpgradeEligibilityQuery } from 'data/config/project-upgrade-eligibility-query'
import { useFlag, useIsFeatureEnabled } from 'hooks'
-import { Alert, Badge, Button, IconPackage, Input } from 'ui'
+import {
+ AlertDescription_Shadcn_,
+ AlertTitle_Shadcn_,
+ Alert_Shadcn_,
+ Badge,
+ Button,
+ Input,
+} from 'ui'
import ProjectUpgradeAlert from '../General/Infrastructure/ProjectUpgradeAlert'
const InfrastructureInfo = () => {
@@ -127,26 +134,71 @@ const InfrastructureInfo = () => {
/>
{showDbUpgrades && data?.eligible && <ProjectUpgradeAlert />}
{showDbUpgrades && !data?.eligible && data?.requires_manual_intervention && (
- <Alert
- icon={<IconPackage className="text-foreground-light" strokeWidth={1.5} />}
- variant="neutral"
- title="A new version of Postgres is available for your project"
- >
- <p className="mb-3">
- Please reach out to us via our support form if you are keen to upgrade your
- Postgres version to the latest available ({latestPgVersion}).
- </p>
- <Link
- href={`/support/new?category=Database_unresponsive&ref=${ref}&subject=${subject}&message=${message}`}
- >
- <a target="_blank" rel="noreferrer">
- <Button size="tiny" type="default">
- Contact support
+ <Alert_Shadcn_ title="A new version of Postgres is available for your project">
+ <AlertTitle_Shadcn_>
+ A new version of Postgres is available for your project
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <p className="mb-3">
+ Please reach out to us via our support form if you are keen to upgrade your
+ Postgres version to the latest available ({latestPgVersion}).
+ </p>
+ <Link
+ href={`/support/new?category=Database_unresponsive&ref=${ref}&subject=${subject}&message=${message}`}
+ passHref
+ >
+ <Button size="tiny" type="default" asChild>
+ <a target="_blank" rel="noreferrer">
+ Contact support
+ </a>
</Button>
- </a>
- </Link>
- </Alert>
+ </Link>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
)}
+ {showDbUpgrades &&
+ !data?.eligible &&
+ (data?.extension_dependent_objects || []).length > 0 && (
+ <Alert_Shadcn_
+ variant="warning"
+ title="A new version of Postgres is available for your project"
+ >
+ <AlertTitle_Shadcn_>New version of Postgres available</AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_ className="flex flex-col gap-3">
+ <div>
+ <p className="mb-1">
+ This project cannot be upgraded due to the following extension dependent
+ objects:
+ </p>
+
+ <ul className="pl-4">
+ {(data?.extension_dependent_objects || []).map((obj) => (
+ <li className="list-disc" key={obj}>
+ {obj}
+ </li>
+ ))}
+ </ul>
+ </div>
+ <p>
+ Once the above objects are exported and removed, you can proceed to
+ upgrade your project, and re-import the objects after the upgrade
+ operation is complete.
+ </p>
+ <div>
+ <Link
+ href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#caveats"
+ passHref
+ >
+ <Button size="tiny" type="default" asChild>
+ <a target="_blank" rel="noreferrer">
+ View docs
+ </a>
+ </Button>
+ </Link>
+ </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ )}
</>
)}
</ScaffoldSectionContent>
diff --git a/studio/components/layouts/ProjectLayout/UpgradingState/UpgradingState.tsx b/studio/components/layouts/ProjectLayout/UpgradingState/UpgradingState.tsx
index 3050d8491c3..86ec8d78e26 100644
--- a/studio/components/layouts/ProjectLayout/UpgradingState/UpgradingState.tsx
+++ b/studio/components/layouts/ProjectLayout/UpgradingState/UpgradingState.tsx
@@ -48,10 +48,11 @@ const UpgradingState = () => {
const isFailed = status === DatabaseUpgradeStatus.Failed
const isCompleted = status === DatabaseUpgradeStatus.Upgraded
- const initiatedAt = dayjs(initiated_at ?? 0).format('DD MMM YYYY HH:mm:ss (ZZ)')
- const initiatedAtUTC = dayjs(initiated_at ?? 0)
- .utc()
- .format('DD MMM YYYY HH:mm:ss')
+ const initiatedAtUTC = dayjs.utc(initiated_at ?? 0).format('DD MMM YYYY HH:mm:ss')
+ const initiatedAt = dayjs
+ .utc(initiated_at ?? 0)
+ .local()
+ .format('DD MMM YYYY HH:mm:ss (ZZ)')
const refetchProjectDetails = async () => {
setLoading(true)
@@ -177,8 +178,8 @@ const UpgradingState = () => {
/>
</div>
) : isCompleted ? (
- <div className="flex items-center justify-center w-5 h-5 border rounded-full bg-brand-300 border-brand-400">
- <IconCheck size={12} className="text-white" strokeWidth={2} />
+ <div className="flex items-center justify-center w-5 h-5 border rounded-full bg-brand border-brand">
+ <IconCheck size={12} className="text-white" strokeWidth={3} />
</div>
) : (
<div className="flex items-center justify-center w-5 h-5 border rounded-full bg-scale-600" />
diff --git a/studio/components/ui/ProjectUpgradeFailedBanner.tsx b/studio/components/ui/ProjectUpgradeFailedBanner.tsx
index f0c85a91d3c..b528e3698de 100644
--- a/studio/components/ui/ProjectUpgradeFailedBanner.tsx
+++ b/studio/components/ui/ProjectUpgradeFailedBanner.tsx
@@ -22,7 +22,8 @@ const ProjectUpgradeFailedBanner = () => {
const [showMessage, setShowMessage] = useState(!isAcknowledged)
const isFailed = status === DatabaseUpgradeStatus.Failed
- const initiatedAtUTC = dayjs(initiated_at ?? 0)
+ const initiatedAtUTC = dayjs
+ .utc(initiated_at ?? 0)
.utc()
.format('DD MMM YYYY HH:mm:ss')
diff --git a/studio/data/config/project-upgrade-eligibility-query.ts b/studio/data/config/project-upgrade-eligibility-query.ts
index d547872b0bc..1dd96207a83 100644
--- a/studio/data/config/project-upgrade-eligibility-query.ts
+++ b/studio/data/config/project-upgrade-eligibility-query.ts
@@ -14,6 +14,9 @@ export type ProjectUpgradeEligibilityResponse = {
target_upgrade_versions: { postgres_version: number; app_version: string }[]
requires_manual_intervention: string | null
potential_breaking_changes: string[]
+ duration_estimate_hours: number
+ legacy_auth_custom_roles: string[]
+ extension_dependent_objects: string[]
}
export async function getProjectUpgradeEligibility(