Page MenuHomeDevCentral

Allow to create MySQL database
ClosedPublic

Authored by dereckson on Apr 3 2018, 02:34.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 21, 20:18
Unknown Object (File)
Fri, Dec 20, 14:50
Unknown Object (File)
Fri, Dec 20, 14:29
Unknown Object (File)
Tue, Dec 17, 00:08
Unknown Object (File)
Mon, Dec 16, 11:13
Unknown Object (File)
Mon, Dec 16, 11:12
Unknown Object (File)
Sun, Dec 15, 23:58
Unknown Object (File)
Fri, Dec 13, 19:11
Subscribers
None

Details

Summary

How can we create a database for a new phpBB instance?

The wrapper script runs on the Docker Engine host
and can interact with the SQLite database there,
but not with the MySQL server, as it's in a container.

The wrapper script will so run a container with this
mainteannce script to create the database.

The wrapper part is implemented at D1524.

Test Plan

saas-phpbb sites:createdb foo

Diff Detail

Repository
rSAASPHPBB saas-phpbb helper command
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dereckson created this revision.
dereckson retitled this revision from WIP: create MySQL database to Allow to create MySQL database.Apr 3 2018, 21:04
dereckson edited the summary of this revision. (Show Details)
dereckson edited the test plan for this revision. (Show Details)

Ensure identifiant is valid. Use PDO in exception mode. Database aren't a named parameter to quote.

Validate identifiants in Site

1. Prepare a directory with the code to test

Dwellers
$ cd  /home/dereckson/dev/docker/phpbb
$ git clone ssh://vcs@devcentral.docker.ulubis/source/saas-phpbb.git
$ cd saas-phpbb
$ arc shell
$ arc patch D1573

2. Run a MySQL container

Same procedure and container than acquisitariat, but called phpbb_db, and without a volume mount.

3. Run a php-cli container

$ mkdir /tmp/data-saas-phpbb
$ docker run -it --rm --link phpbb_db:db -e SAAS_SITES_DB=/data/sites.db -v /tmp/data-saas-phpbb:/data -v /home/dereckson/dev/docker/phpbb/saas-phpbb:/app nasqueron/php-cli bash
$ make
$ saas-phpbb sites:bootstrap

4. Add test data in sites.db

$ sqlite /tmp/data-saas-phpbb/sites.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE sites (
  id text,
  host text,
  db_user text,
  db_password text,
  db_prefix text,
  active boolean
);
sqlite> INSERT INTO sites VALUES ('acme', 'phpbb.acme.tld', 'acme', 'somepass', 'phpbb_', 1);
sqlite> 

5. Go back to our php-cli container to test this change

$ php bin/saas-phpbb.php sites:createdb acme

6. Fire a MySQL client to check we can connect to the created database with the created account

$ docker run -it --link phpbb_db:mysql --rm nasqueron/mysql bash
$ mysql -hmysql -uacme -p acme
Enter password: somepass
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql>
This revision is now accepted and ready to land.Apr 4 2018, 00:03
This revision was automatically updated to reflect the committed changes.