-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow user to select a different database type #124
feat: Allow user to select a different database type #124
Conversation
…' into deloris/issue47/allow-user-to-select-a-different-database-type
…se-type' of https://github.com/echobind/bisonapp into deloris/issue47/allow-user-to-select-a-different-database-type
break; | ||
default: 5432; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we make the suggested change above, we can change to:
{
default: (answers) =>. {
const database = SUPPORTED_DATABASES.find(d => d.value === answers.db.dev.databaseType);
if (!database) return SUPPORTED_DATABASES.POSTGRES.value;
return database.value;
}
}
I'm not sure the default port as postgres actually buys us anything, but it's good to be defensive about it 👍
choices: [ | ||
{ name: "Postgres", value: "postgres" }, | ||
{ name: "MySQL", value: "MySQL" }, | ||
{ name: "SQLite", value: "SQLite" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding an array of supported databases as a constant? I haven't tested this, but the following should work:
const SUPPORTED_DATABASES = {
postgres: { label: "Postgres", defaultPort: 5432 },
mysql: { label: "MySQL", defaultPort: 3306 },
sqlite: { label: "SQLite", defaultPort: "file:./dev.db" },
}
// use it to create the choices
{
choices: Object.values(SUPPORTED_DATABASES)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It changes some of the methods, but instead of just checking against postgres
everywhere we can keep the information in one place.
type: "confirm", | ||
message: "Visit https://github.com/echobind/bisonapp/blob/main/docs/postgres.md for intructions to setup a new database.\n\bContinue? Press [Enter] for YES", | ||
description: "Provide link to help install Postgres", | ||
when: (answers) => answers.db.dev.localDatabasePrompt == false && answers.db.dev.databaseType == "postgres", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when: (answers) => answers.db.dev.localDatabasePrompt == false && answers.db.dev.databaseType == "postgres", | |
when: (answers) => answers.db.dev.localDatabasePrompt === false && answers.db.dev.databaseType === SUPPORTED_DATABASES.POSTGRES.value, |
we'll rework this with the CLI rework. |
Changes
Screenshots
List of Database Types
User.toggles.between.database.types.mp4
Database Port set Based on Selected Type
Checklist
-[X] Requires adding MySQL and SQLite to app creation
Fixes: Issue128