Skip to content

Commit e1535b9

Browse files
committed
major release: 0.1.0
- Moved everything to src folder - Upgraded to a composer package - Configuration object instead of manual editing the project - Added migrations inside a transaction for failsafe - removed .idea folder - updated readme.md - fixed migrations running multiple times - migration table is created automatically with an option to disable it
1 parent a0e319a commit e1535b9

20 files changed

+355
-369
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

.idea/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/php.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/workspace.xml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.idea/wp-migration.iml

Lines changed: 0 additions & 8 deletions
This file was deleted.

architecture/DBUtils.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

architecture/Repository.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "skipthedragon/wp-migrations",
3+
"description": "Doctrine like Migrations in WordPress.",
4+
"type": "library",
5+
"version": "0.1.0",
6+
"license": "Apache-2.0 license",
7+
"authors": [
8+
{
9+
"name": "Tudorache Leonard Valentin",
10+
"email": "tudorache.leonard@wyverr.com"
11+
}
12+
],
13+
"require-dev": {
14+
"php": ">=8.1"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"WpMigrations\\": "src/",
19+
"WpMigrations\\Repository\\": "src/repository/",
20+
"WpMigrations\\Architecture\\": "src/architecture/",
21+
"WpMigrations\\Service\\": "src/service/"
22+
},
23+
"files": [
24+
"src/function/isTimestamp.php"
25+
]
26+
},
27+
"minimum-stability": "stable",
28+
"require": {}
29+
}

composer.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

migration/MigrationV1707157782.php renamed to examples/MigrationV1707157782.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?php
22

3-
namespace WpMigrations\Migration;
4-
5-
use WpMigrations\Architecture\DBUtils;
6-
use WpMigrations\Architecture\Migration;
3+
use WpMigrations\architecture\Migration;
74

85
/**
96
* Migration example.
@@ -18,8 +15,6 @@
1815
* @since 1.0
1916
*/
2017
class MigrationV1707157782 implements Migration {
21-
use DBUtils;
22-
2318
public function up(): void {
2419

2520
}

readme.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ Heavily inspired by Symfony/Doctrine migrations, this package provides a simple
44

55
### Installation
66

7-
1. Copy the folders in your plugin and change the namespaces if your app has autoloading.
8-
2. Search for @todo in the code and replace with your own values.
9-
3. Check `Usage` for more details.
7+
```bash
8+
composer require skipthedragon/wp-migrations
9+
```
1010

11-
### Dependencies
11+
### Pre-requisites
1212

13-
As this package is meant to be used in a WordPress environment, it depends on the following packages:
13+
This package requires:
1414
- `wpdb` (WordPress database)
15+
- at least PHP 8.1
1516

1617
### Prerequisites
1718

1819
Migrations must:
19-
- be in the migration folder that you specified in the config file (`service/MigrationManagerService.php`)
20+
- be in the migration folder that you specified in the config
2021
- have a unique timestamp in its name
2122
- implement the Migration interface (`WpMigrations\Architecture\Migration`)
2223
- have `MigrationV` in its name
@@ -26,9 +27,15 @@ Migrations must:
2627
To run the migrations, you can use the following code:
2728

2829
```php
29-
use WpMigrations\Service\MigrationManagerService;
30+
use WpMigrations\service\MigrationManagerService;
31+
32+
$config = new \WpMigrations\Architecture\MigrationConfig(
33+
'path/to/migrations',
34+
'WpMigrations\\Migrations\\',
35+
'my_plugin_name'
36+
);
3037

31-
$migrationManagerService = new MigrationManagerService();
38+
$migrationManagerService = new MigrationManagerService($config);
3239
$migrationManagerService->migrate();
3340
```
3441

repository/MigrationRepository.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)