Skip to content

12. Dev.Setup

Simon Striekwold edited this page Mar 29, 2018 · 3 revisions

The setup functionality automatically creates your database and loads it with test data. If the database already exists it resets the database and loads it with clean test data.

To (re)load the database:

  1. Make sure Debug is set to true in the config.
  2. Go to the URL /dev/setup, and click Reset database.

To change the structure of the database:

In the database_struct.php file add a new first level array entry to add a new table, and add an array entry in a table entry to add a column. The key of a column entry is the name of the column and the value is the datatype and length. To findout what you can enter here, go to the structure tab in your phpmyadmin, and see the type of the column.

To add a primary key, add an array entry in the primaryKeys array. The key is the table and the value is the column.

public static function getStructure() {
    return [
        'user' => [
            'id' => 'varchar(256)',
            'name' => 'varchar(256)'
        ],

        'primaryKeys' => [
            'user' => 'id'
        ]
    ];
}

To change the testdata in database:

Add generating code to the getData function.

public static function getData() {...}