Page MenuHomeDevCentral

Allow to create MySQL database
ClosedPublic

Authored by dereckson on Apr 3 2018, 02:34.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 22, 17:21
Unknown Object (File)
Fri, Nov 22, 16:17
Unknown Object (File)
Fri, Nov 22, 16:17
Unknown Object (File)
Fri, Nov 22, 15:33
Unknown Object (File)
Fri, Nov 22, 09:58
Unknown Object (File)
Wed, Nov 20, 09:09
Unknown Object (File)
Wed, Nov 20, 08:46
Unknown Object (File)
Mon, Nov 18, 15:31
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.