Skip to content

Conversation

@JmzTaylor
Copy link
Contributor

Matches defaults in MySQL 8+. Doesn't throw error if charset or collection doesn't exist.

Fixes #939 #760

@saeedvaziry
Copy link
Member

Thanks for the PR. How this will work for Postgresql?

@JmzTaylor
Copy link
Contributor Author

JmzTaylor commented Dec 26, 2025

It doesn't change anything for Postgresql. It will show up exactly as before.

@saeedvaziry
Copy link
Member

No I mean we should also select default values for Postgres as well

@JmzTaylor JmzTaylor force-pushed the feature-database-select branch from 995fad2 to 3ea82f6 Compare December 27, 2025 02:44
@JmzTaylor
Copy link
Contributor Author

Updated the commit. This will gracefully fallback to current behavior if the default charset or collation doesn't exist.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for automatically selecting default charset and collation values when creating databases, matching MySQL 8+ defaults. The changes gracefully handle cases where the specified charset or collation doesn't exist on the server.

  • Determines database type and sets appropriate defaults (UTF8/C.utf8 for PostgreSQL, utf8mb4/utf8mb4_0900_ai_ci for MySQL)
  • Updates the CreateDatabase component to accept and use these default values
  • Modifies the useEffect to load collations based on the form's current charset rather than only the default

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
resources/js/pages/databases/index.tsx Adds logic to determine database type and set appropriate default charset/collation values, then passes them to the CreateDatabase component
resources/js/pages/databases/components/create-database.tsx Updates the useEffect to use form.data.charset instead of defaultCharset for loading collations dynamically

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 66 to +72
useEffect(() => {
if (open && defaultCharset && charsets.includes(defaultCharset) && collations.length === 0) {
axios.get(route('databases.collations', { server: server, charset: defaultCharset })).then((response) => {
if (open && form.data.charset && charsets.includes(form.data.charset) && collations.length === 0) {
axios.get(route('databases.collations', { server: server, charset: form.data.charset })).then((response) => {
setCollations(response.data);
});
}
}, [open, charsets, defaultCharset, server, collations]);
}, [open, charsets, form.data.charset, server, collations]);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collations state is not reset when the modal closes or when the form is submitted successfully. This means that on subsequent opens of the modal, the useEffect will not run because the condition 'collations.length === 0' will be false, and the collations list will still contain values from the previous interaction. Consider resetting the collations state in the handleOpenChange function when open is false, or after form submission.

Copilot uses AI. Check for mistakes.
</a>
<SyncDatabases server={page.props.server} />
<CreateDatabase server={page.props.server.id}>
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two consecutive spaces between the server prop and defaultCharset prop. Remove the extra space for consistent formatting.

Suggested change
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>

Copilot uses AI. Check for mistakes.
@saeedvaziry saeedvaziry merged commit f61b5c0 into vitodeploy:3.x Jan 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default database configuration

2 participants