Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop: (24 commits)
  specify next release
  add readme
  add transactions documentation
  add commands documentation
  add sql documentation
  fix psalm
  setup documentation
  fix test
  add missing return type
  add changelog
  fix test failing on second run
  give access to the latest error
  add factory to have a fluent api to run migrations
  add Runner interface to make sure the same api between kinds of migration
  deduplicate code
  make sure to stop migrating when a migration fails
  fix invalid nullable type
  add commands migrations
  remove unused variable
  only run on linux
  ...
  • Loading branch information
Baptouuuu committed Oct 4, 2024
2 parents 99bf233 + 9e4267d commit 6fd72a9
Show file tree
Hide file tree
Showing 41 changed files with 2,729 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.github export-ignore
/proofs export-ignore
/fixtures export-ignore
35 changes: 27 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ on: [push, pull_request]

jobs:
blackbox:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3', '8.4']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
mariadb: ['10', '11']
name: BlackBox
services:
mariadb:
image: mariadb:${{ matrix.mariadb }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: example
ports:
- 3306
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -26,14 +34,24 @@ jobs:
dependency-versions: ${{ matrix.dependencies }}
- name: BlackBox
run: php blackbox.php
env:
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
coverage:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3', '8.4']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: BlackBox
mariadb: ['10', '11']
name: Coverage
services:
mariadb:
image: mariadb:${{ matrix.mariadb }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: example
ports:
- 3306
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -51,14 +69,15 @@ jobs:
run: php blackbox.php
env:
ENABLE_COVERAGE: 'true'
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2', '8.3', '8.4']
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Documentation
on:
push:
branches: [main]

permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/composer.lock
/vendor
/.cache
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## 1.0.0 - 2024-10-04

### Added

- `Formal\Migrations\Factory`
- `Formal\Migrations\SQL`
- `Formal\Migrations\SQL\Migration`
- `Formal\Migrations\SQL\Load`
- `Formal\Migrations\Commands`
- `Formal\Migrations\Commands\Migration`
- `Formal\Migrations\Commands\Reference`
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This command is intended to be run on your computer
serve-doc:
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material

build-doc:
docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material build
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# migrations

[![Build Status](https://github.com/formal/migrations/workflows/CI/badge.svg?branch=main)](https://github.com/formal/migrations/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/formal/migrations/branch/develop/graph/badge.svg)](https://codecov.io/gh/formal/migrations)
[![Type Coverage](https://shepherd.dev/github/formal/migrations/coverage.svg)](https://shepherd.dev/github/formal/migrations)
[![Build Status](https://github.com/formal-php/migrations/workflows/CI/badge.svg?branch=main)](https://github.com/formal-php/migrations/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/formal-php/migrations/branch/develop/graph/badge.svg)](https://codecov.io/gh/formal-php/migrations)
[![Type Coverage](https://shepherd.dev/github/formal-php/migrations/coverage.svg)](https://shepherd.dev/github/formal-php/migrations)

Description
This library is a simple one way migration system.

You can run both SQL and Commands migrations.

## Installation

Expand All @@ -14,4 +16,30 @@ composer require formal/migrations

## Usage

Todo
```php
use Formal\Migrations\Factory;
use Innmind\OperatingSystem\Factory as OS;
use Innmind\Url\{
Url,
Path,
};

$dsn = Url::of('mysql://user:[email protected]:3306/database');

Factory::of(OS::build())
->storeVersionsInDatabase($dsn)
->sql()
->files(Path::of('migrations/folder/'))
->migrate($dsn)
->match(
static fn() => print('Everything has been migrated'),
static fn(\Throwable $error) => printf(
'Migrations failed with the message : %s',
$error->getMessage(),
),
);
```

## Documentation

Full documentation available [here](https://formal-php.github.io/migrations/).
2 changes: 1 addition & 1 deletion blackbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Application::new($argv)
->when(
\get_env('ENABLE_COVERAGE') !== false,
\getenv('ENABLE_COVERAGE') !== false,
static fn(Application $app) => $app
->scenariiPerProof(1)
->codeCoverage(
Expand Down
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "",
"keywords": [],
"homepage": "http://github.com/formal/migrations",
"homepage": "http://github.com/formal-php/migrations",
"license": "MIT",
"authors": [
{
Expand All @@ -12,19 +12,26 @@
}
],
"support": {
"issues": "http://github.com/formal/migrations/issues"
"issues": "http://github.com/formal-php/migrations/issues"
},
"require": {
"php": "~8.2"
"php": "~8.2",
"innmind/operating-system": "~5.2",
"formal/orm": "~3.4"
},
"autoload": {
"psr-4": {
"formal\\migrations\\": "src/"
"Formal\\Migrations\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Fixtures\\Formal\\Migrations\\": "fixtures/"
}
},
"require-dev": {
"vimeo/psalm": "~5.13",
"innmind/black-box": "^5.6.1",
"innmind/black-box": "~5.7",
"innmind/coding-standard": "~2.0"
}
}
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
mariadb:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: example
ports:
- '3306:3306'
Binary file added documentation/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
22 changes: 22 additions & 0 deletions documentation/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions documentation/assets/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@font-face {
font-family: "Monaspace Neon";
font-weight: normal;
font-style: normal;
src: url("../fonts/MonaspaceNeon-Regular.woff");
}

:root {
--md-code-font: "Monaspace Neon";
}

:root {
--light-md-code-hl-number-color: #f76d47;
--light-md-code-hl-function-color: #6384b9;
--light-md-code-hl-operator-color: #39adb5;
--light-md-code-hl-constant-color: #7c4dff;
--light-md-code-hl-string-color: #9fc06f;
--light-md-code-hl-punctuation-color: #39adb5;
--light-md-code-hl-keyword-color: #7c4dff;
--light-md-code-hl-variable-color: #80cbc4;
--light-md-code-hl-comment-color: #ccd7da;
--light-md-code-bg-color: #fafafa;
--light-md-code-fg-color: #ffb62c;
--light-md-code-hl-variable-color: #6384b9;
--dark-md-code-hl-number-color: #f78c6c;
--dark-md-code-hl-function-color: #82aaff;
--dark-md-code-hl-operator-color: #89ddff;
--dark-md-code-hl-constant-color: #c792ea;
--dark-md-code-hl-string-color: #c3e88d;
--dark-md-code-hl-punctuation-color: #89ddff;
--dark-md-code-hl-keyword-color: #c792ea;
--dark-md-code-hl-variable-color: #e8f9f9;
--dark-md-code-hl-comment-color: #546e7a;
--dark-md-code-bg-color: #263238;
--dark-md-code-fg-color: #ffcb6b;
--dark-md-code-hl-variable-color: #82aaff;
}

@media (prefers-color-scheme: light) {
.language-php > * {
--md-code-hl-number-color: var(--light-md-code-hl-number-color);
--md-code-hl-function-color: var(--light-md-code-hl-function-color);
--md-code-hl-operator-color: var(--light-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--light-md-code-hl-constant-color);
--md-code-hl-string-color: var(--light-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--light-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--light-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--light-md-code-hl-comment-color);
--md-code-bg-color: var(--light-md-code-bg-color);
--md-code-fg-color: var(--light-md-code-fg-color);
}

.language-php .na {
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
}
}

[data-md-color-media="(prefers-color-scheme: light)"] .language-php > * {
--md-code-hl-number-color: var(--light-md-code-hl-number-color);
--md-code-hl-function-color: var(--light-md-code-hl-function-color);
--md-code-hl-operator-color: var(--light-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--light-md-code-hl-constant-color);
--md-code-hl-string-color: var(--light-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--light-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--light-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--light-md-code-hl-comment-color);
--md-code-bg-color: var(--light-md-code-bg-color);
--md-code-fg-color: var(--light-md-code-fg-color);
}

[data-md-color-media="(prefers-color-scheme: light)"] .language-php .na {
--md-code-hl-variable-color: var(--light-md-code-hl-variable-color);
}

@media (prefers-color-scheme: dark) {
.language-php > * {
--md-code-hl-number-color: var(--dark-md-code-hl-number-color);
--md-code-hl-function-color: var(--dark-md-code-hl-function-color);
--md-code-hl-operator-color: var(--dark-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--dark-md-code-hl-constant-color);
--md-code-hl-string-color: var(--dark-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--dark-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--dark-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--dark-md-code-hl-comment-color);
--md-code-bg-color: var(--dark-md-code-bg-color);
--md-code-fg-color: var(--dark-md-code-fg-color);
}

.language-php .na {
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
}
}

[data-md-color-media="(prefers-color-scheme: dark)"] .language-php > * {
--md-code-hl-number-color: var(--dark-md-code-hl-number-color);
--md-code-hl-function-color: var(--dark-md-code-hl-function-color);
--md-code-hl-operator-color: var(--dark-md-code-hl-operator-color);
--md-code-hl-constant-color: var(--dark-md-code-hl-constant-color);
--md-code-hl-string-color: var(--dark-md-code-hl-string-color);
--md-code-hl-punctuation-color: var(--dark-md-code-hl-punctuation-color);
--md-code-hl-keyword-color: var(--dark-md-code-hl-keyword-color);
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
--md-code-hl-comment-color: var(--dark-md-code-hl-comment-color);
--md-code-bg-color: var(--dark-md-code-bg-color);
--md-code-fg-color: var(--dark-md-code-fg-color);
}

[data-md-color-media="(prefers-color-scheme: dark)"] .language-php .na {
--md-code-hl-variable-color: var(--dark-md-code-hl-variable-color);
}
Loading

0 comments on commit 6fd72a9

Please sign in to comment.