Skip to content
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

Conversation

deloristhompson
Copy link
Contributor

@deloristhompson deloristhompson commented Dec 31, 2020

  • Provides a multiple-choice list of database types
  • Default port is set based on the selected database type

Changes

  • 3 database options instead of 1

Screenshots

List of Database Types

User.toggles.between.database.types.mp4

Database Port set Based on Selected Type

SQLite port

Checklist

-[X] Requires adding MySQL and SQLite to app creation

  • Requires dependency update?
  • Generating a new app works

Fixes: Issue128

@deloristhompson deloristhompson added the work in progress PR is a work in progress and not ready to merge label Dec 31, 2020
@deloristhompson deloristhompson self-assigned this Dec 31, 2020
@deloristhompson deloristhompson added this to In progress in Bison via automation Dec 31, 2020
@deloristhompson deloristhompson marked this pull request as draft December 31, 2020 18:56
@deloristhompson deloristhompson changed the title Deloris/issue47/allow user to select a different database type fix: Deloris/issue47/allow user to select a different database type Jan 6, 2021
@deloristhompson deloristhompson changed the title fix: Deloris/issue47/allow user to select a different database type feat: Deloris/issue47/allow user to select a different database type Jan 6, 2021
@deloristhompson deloristhompson changed the title feat: Deloris/issue47/allow user to select a different database type feat: Allow user to select a different database type Jan 6, 2021
break;
default: 5432;
break;
}
Copy link
Member

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" },
Copy link
Member

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)
}

Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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,

@cball
Copy link
Member

cball commented Nov 5, 2021

we'll rework this with the CLI rework.

@cball cball closed this Nov 5, 2021
Bison automation moved this from In progress to Done Nov 5, 2021
@cball cball deleted the deloris/issue47/allow-user-to-select-a-different-database-type branch November 5, 2021 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work in progress PR is a work in progress and not ready to merge
Projects
Bison
  
Done
Development

Successfully merging this pull request may close these issues.

Dev: Add MySQL and SQLite to project (currently only has Postgres)
2 participants