-
Notifications
You must be signed in to change notification settings - Fork 507
fix(upgrade): drop morph indexes before columns and baseline 000071 #2713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wychoong
wants to merge
6
commits into
lunarphp:2.x
Choose a base branch
from
wychoong:fix/upgrade-v1-schema
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
093b16d
Add a CI workflow that upgrades vanilla Lunar 1.5 core to this v2 tree.
wychoong 35920f6
Fix upgrade workflow env overrides and concurrency.
wychoong 15f883a
Fix workflow parse error and run the full upgrade on all four databases.
wychoong 842b995
Run the upgrade-command workflow on 2.x only.
wychoong 0251f3e
fix(upgrade): drop morph indexes before columns and baseline 000071
wychoong 887bcf0
fix(upgrade): drop SQLite btree indexes and skip missing staff baseline
wychoong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| name: Upgrade command | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [2.x] | ||
| paths: | ||
| - packages/upgrade/** | ||
| - packages/core/database/migrations/** | ||
| - .github/workflows/upgrade-command.yml | ||
| pull_request: | ||
| branches: [2.x] | ||
| paths: | ||
| - packages/upgrade/** | ||
| - packages/core/database/migrations/** | ||
| - .github/workflows/upgrade-command.yml | ||
|
|
||
| jobs: | ||
| lunar-upgrade: | ||
| name: v1.5 to v2 (${{ matrix.database }}) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - database: sqlite | ||
| db_connection: sqlite | ||
| db_database: /tmp/vanilla-lunar/database/database.sqlite | ||
| - database: mysql | ||
| db_connection: mysql | ||
| db_port: "3306" | ||
| db_database: lunar_upgrade | ||
| db_username: root | ||
| db_password: root | ||
| - database: postgres | ||
| db_connection: pgsql | ||
| db_port: "5432" | ||
| db_database: lunar_upgrade | ||
| db_username: postgres | ||
| db_password: postgres | ||
| - database: mariadb | ||
| db_connection: mariadb | ||
| db_port: "3307" | ||
| db_database: lunar_upgrade | ||
| db_username: root | ||
| db_password: root | ||
| env: | ||
| APP_DIR: /tmp/vanilla-lunar | ||
| LUNAR_V1: "1.5.0" | ||
| APP_ENV: local | ||
| APP_DEBUG: "true" | ||
| SCOUT_DRIVER: collection | ||
| QUEUE_CONNECTION: sync | ||
| DB_CONNECTION: ${{ matrix.db_connection }} | ||
| DB_HOST: 127.0.0.1 | ||
| DB_PORT: ${{ matrix.db_port }} | ||
| DB_DATABASE: ${{ matrix.db_database }} | ||
| DB_USERNAME: ${{ matrix.db_username }} | ||
| DB_PASSWORD: ${{ matrix.db_password }} | ||
| services: | ||
| mysql: | ||
| image: mysql:8.0 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_DATABASE: lunar_upgrade | ||
| ports: | ||
| - 3306:3306 | ||
| options: >- | ||
| --health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=10 | ||
| mariadb: | ||
| image: mariadb:11 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_DATABASE: lunar_upgrade | ||
| ports: | ||
| - 3307:3306 | ||
| options: >- | ||
| --health-cmd="mariadb-admin ping -h 127.0.0.1 -uroot -proot" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=10 | ||
| postgres: | ||
| image: postgres:16 | ||
| env: | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: lunar_upgrade | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd="pg_isready -U postgres" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: "8.5" | ||
| extensions: bcmath, exif, intl, mbstring, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite | ||
| tools: composer:v2 | ||
| coverage: none | ||
|
|
||
| - name: Create Laravel 13 app | ||
| run: composer create-project laravel/laravel:^13.0 "$APP_DIR" --prefer-dist --no-interaction --no-dev | ||
|
|
||
| - name: Configure app | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: | | ||
| php artisan key:generate --force --no-interaction | ||
| if [ "${{ matrix.database }}" = "sqlite" ]; then | ||
| mkdir -p database | ||
| touch database/database.sqlite | ||
| fi | ||
| { | ||
| echo "APP_ENV=local" | ||
| echo "APP_DEBUG=true" | ||
| echo "SCOUT_DRIVER=collection" | ||
| echo "QUEUE_CONNECTION=sync" | ||
| echo "DB_CONNECTION=$DB_CONNECTION" | ||
| echo "DB_HOST=$DB_HOST" | ||
| echo "DB_PORT=$DB_PORT" | ||
| echo "DB_DATABASE=$DB_DATABASE" | ||
| echo "DB_USERNAME=$DB_USERNAME" | ||
| echo "DB_PASSWORD=$DB_PASSWORD" | ||
| } >> .env | ||
|
|
||
| - name: Install Lunar v1.5 core | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: composer require "lunarphp/core:${LUNAR_V1}" --no-interaction --no-progress | ||
|
|
||
| - name: Migrate v1 schema | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: php artisan migrate --force --no-interaction | ||
|
|
||
| - name: Switch app to this v2 checkout | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: | | ||
| composer config minimum-stability dev | ||
| composer config prefer-stable true | ||
| composer config repositories.lunar-core "{\"type\":\"path\",\"url\":\"${GITHUB_WORKSPACE}/packages/core\",\"options\":{\"symlink\":true}}" | ||
| composer config repositories.lunar-upgrade "{\"type\":\"path\",\"url\":\"${GITHUB_WORKSPACE}/packages/upgrade\",\"options\":{\"symlink\":true}}" | ||
| composer require lunarphp/core:@dev lunarphp/upgrade:@dev --no-interaction --no-progress --with-all-dependencies | ||
|
|
||
| - name: Run lunar:upgrade | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: php artisan lunar:upgrade --no-interaction | ||
|
|
||
| - name: Apply remaining migrations | ||
| working-directory: /tmp/vanilla-lunar | ||
| run: php artisan migrate --force --no-interaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| use Illuminate\Database\ConnectionResolverInterface; | ||
| use Illuminate\Database\Migrations\Migrator; | ||
| use Illuminate\Support\Facades\Schema; | ||
| use Lunar\Upgrade\Support\StepReport; | ||
|
|
||
| /** | ||
|
|
@@ -19,7 +20,8 @@ | |
| * the app's own files do not, and deleting their rows would make `migrate` | ||
| * re-run them), and a baseline row is only inserted when its file is present | ||
| * (marking-run a migration from an uninstalled sub-package would silently | ||
| * skip it if that package is installed later). | ||
| * skip it if that package is installed later). Staff is extra: the create | ||
| * file now lives in core, so we also require the table to exist. | ||
| */ | ||
| class LedgerRewriteStep implements UpgradeStep | ||
| { | ||
|
|
@@ -72,7 +74,8 @@ public function run(StepContext $context): void | |
|
|
||
| $toInsert = array_values(array_filter( | ||
| array_diff($config['v2_baseline'], $existing), | ||
| fn (string $migration): bool => isset($known[$migration]), | ||
| fn (string $migration): bool => isset($known[$migration]) | ||
| && $this->baselineSchemaPresent($migration, $context->connection), | ||
| )); | ||
|
|
||
| if ($context->dryRun) { | ||
|
|
@@ -107,6 +110,23 @@ public function run(StepContext $context): void | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Staff lived in the v1 admin package. v2 folded `create_staff` into core, | ||
| * so the migration file is always present even when the table was never | ||
| * created (core-only / headless v1). Marking it run would skip the create | ||
| * and leave later core staff migrations altering a missing table. | ||
| */ | ||
| protected function baselineSchemaPresent(string $migration, ?string $connection): bool | ||
| { | ||
| if ($migration !== '2026_01_01_900000_create_staff_table') { | ||
| return true; | ||
| } | ||
|
|
||
| return Schema::connection($connection)->hasTable( | ||
| config('lunar.database.table_prefix').'staff', | ||
| ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in v1 staff is in panel package, so there is a chance someone using lunarphp for core without panel |
||
| } | ||
|
|
||
| /** | ||
| * Migration names the application can currently load, keyed by name — | ||
| * every path registered with the migrator (package `loadMigrationsFrom` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems a few more sqlite specific issue, not sure worth handling for upgrade command as unlikely anyone using it for prod