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

remove db_name env in database.postgres #76

Closed
wants to merge 1 commit into from

Conversation

ccpz
Copy link
Contributor

@ccpz ccpz commented Sep 30, 2019

DB_NAME env will create a new database:

https://github.com/sameersbn/docker-postgresql#creating-databases

but src/configure-db.php will only initialize database when database is not exist:

https://github.com/ccpz/Awesome-TTRSS/blob/master/src/configure-db.php#L22

Therefore if db_name exist, it won't initial database schema at first run

DB_NAME env will create a new database:

https://github.com/sameersbn/docker-postgresql#creating-databases

but src/configure-db.php will only initialize database when database is not exist:

https://github.com/ccpz/Awesome-TTRSS/blob/master/src/configure-db.php#L22

Therefore if db_name exist, it won't initial database schema at first run
@HenryQW
Copy link
Owner

HenryQW commented Oct 4, 2019

This comes back to #69 again, DB_NAME is required to get pg_trgm initialized in database.postgres.

I think it's possible to remove:

if(!dbcheckdb($config)){
echo 'Database not found, creating.'. PHP_EOL ;
$pdo = dbconnect($config);
$pdo -> exec('CREATE DATABASE ' . ($config['DB_NAME']) . ' WITH OWNER ' . ($config['DB_USER']));
unset($pdo);
$pdo = dbexist($config);

and get it working.

I'm not a php developer so I'd rather keep it as it is, you are welcome to optimize it.

I've proposed #79 for fixing the issue.

@HenryQW HenryQW closed this in #79 Oct 4, 2019
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.

None yet

2 participants