Skip to content

Commit add0179

Browse files
committed
Merge branch 'dev' of https://github.com/WebFiori/framework into dev
2 parents c4841a8 + fd6c65d commit add0179

File tree

12 files changed

+502
-20
lines changed

12 files changed

+502
-20
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multi;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration000 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('Third One', 2);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
//TODO: Implement the action which will apply the migration to database.
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
//TODO: Implement the action which will revert back the migration.
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multi;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration001 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('Second one', 1);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
//TODO: Implement the action which will apply the migration to database.
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
//TODO: Implement the action which will revert back the migration.
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multi;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration002 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('First One', 0);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
//TODO: Implement the action which will apply the migration to database.
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
//TODO: Implement the action which will revert back the migration.
31+
}
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace app\database\migrations\multi;
3+
4+
use webfiori\database\ConnectionInfo;
5+
use webfiori\database\migration\MigrationsRunner;
6+
use const APP_PATH;
7+
use const DS;
8+
9+
10+
class MultiRunner extends MigrationsRunner {
11+
12+
public function __construct() {
13+
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', SQL_SERVER_HOST, 1433, [
14+
'TrustServerCertificate' => 'true'
15+
]);
16+
parent::__construct(APP_PATH.'database'.DS.'migrations'.DS.'multi', '\\app\\database\\migrations\\multi', $conn);
17+
}
18+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multiErr;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration000 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('Third One', 2);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
$schema->x();
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
$schema->y();
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multiErr;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration001 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('Second one', 1);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
//TODO: Implement the action which will apply the migration to database.
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
//TODO: Implement the action which will revert back the migration.
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace app\database\migrations\multiErr;
3+
4+
use webfiori\database\Database;
5+
use webfiori\database\migration\AbstractMigration;
6+
/**
7+
* A database migration class.
8+
*/
9+
class Migration002 extends AbstractMigration {
10+
/**
11+
* Creates new instance of the class.
12+
*/
13+
public function __construct() {
14+
parent::__construct('First One', 0);
15+
}
16+
/**
17+
* Performs the action that will apply the migration.
18+
*
19+
* @param Database $schema The database at which the migration will be applied to.
20+
*/
21+
public function up(Database $schema) {
22+
//TODO: Implement the action which will apply the migration to database.
23+
}
24+
/**
25+
* Performs the action that will revert back the migration.
26+
*
27+
* @param Database $schema The database at which the migration will be applied to.
28+
*/
29+
public function down(Database $schema) {
30+
//TODO: Implement the action which will revert back the migration.
31+
}
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace app\database\migrations\multiErr;
3+
4+
use webfiori\database\ConnectionInfo;
5+
use webfiori\database\migration\MigrationsRunner;
6+
use const APP_PATH;
7+
use const DS;
8+
9+
10+
class MultiErrRunner extends MigrationsRunner {
11+
12+
public function __construct() {
13+
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', SQL_SERVER_HOST, 1433, [
14+
'TrustServerCertificate' => 'true'
15+
]);
16+
parent::__construct(APP_PATH.'database'.DS.'migrations'.DS.'multiErr', '\\app\\database\\migrations\\multiErr', $conn);
17+
}
18+
}

tests/bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
66

7+
use webfiori\database\ConnectionInfo;
8+
use webfiori\database\migration\MigrationsRunner;
79
use webfiori\framework\App;
810
use webfiori\framework\autoload\ClassLoader;
911
use webfiori\framework\config\JsonDriver;
@@ -12,6 +14,7 @@
1214

1315
//the name of tests directory. Update as needed.
1416
define('TESTS_DIRECTORY', 'tests');
17+
define('SQL_SERVER_HOST', 'localhost');
1518
//an array that contains possible locations at which
1619
//WebFiori Framework might exist.
1720
//Add and remove directories as needed.
@@ -99,6 +102,11 @@
99102
App::getConfig()->remove();
100103
JsonDriver::setConfigFileName('super-confx.json');
101104
App::getConfig()->remove();
105+
$conn = new ConnectionInfo('mssql', 'sa', '1234567890@Eu', 'testing_db', SQL_SERVER_HOST, 1433, [
106+
'TrustServerCertificate' => 'true'
107+
]);
108+
$runner = new MigrationsRunner(APP_PATH, '', $conn);
109+
$runner->dropMigrationsTable();
102110
});
103111
fprintf(STDOUT, "Registering shutdown function completed.\n");
104112
fprintf(STDOUT,"---------------------------------\n");

0 commit comments

Comments
 (0)