Page MenuHomeDevCentral

Allow to create MySQL database
ClosedPublic

Authored by dereckson on Apr 3 2018, 02:34.
Tags
None
Referenced Files
F2851492: D1573.id4023.diff
Thu, Apr 25, 20:32
F2850540: D1573.id4023.diff
Thu, Apr 25, 15:16
F2849433: D1573.id4021.diff
Thu, Apr 25, 04:31
Unknown Object (File)
Wed, Apr 24, 18:24
Unknown Object (File)
Wed, Apr 24, 08:23
Unknown Object (File)
Wed, Apr 24, 00:15
Unknown Object (File)
Wed, Apr 24, 00:15
Unknown Object (File)
Tue, Apr 23, 17:45
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 Passed
Unit
Test Failures
Branch
createdb (branched from master)
Build Status
Buildable 2464
Build 2712: arc lint + arc unit

Unit TestsBroken

TimeTest
5 msUnknown Unit Message ("")
Nasqueron\SAAS\PhpBB\Tests\Tasks\BootstrapSqliteRepositoryTest::testBootstrapWithDefaultFile Error: Call to undefined method Nasqueron\SAAS\PhpBB\Tasks\BootstrapSqliteRepository::getDefaultFilename()
5 msUnknown Unit Message ("")

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.