Skip to content
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

✨ Database support #277

Merged
merged 3 commits into from
Jun 13, 2023
Merged

✨ Database support #277

merged 3 commits into from
Jun 13, 2023

Conversation

retlehs
Copy link
Sponsor Member

@retlehs retlehs commented Feb 22, 2023

This PR adds illuminate/database as a dependency and enables migration commands:

$ wp acorn migrate

$ wp acorn db:seed
$ wp acorn db:wipe 

$ wp acorn make:migration

$ wp acorn migrate:fresh
$ wp acorn migrate:install
$ wp acorn migrate:refresh
$ wp acorn migrate:reset
$ wp acorn migrate:rollback
$ wp acorn migrate:status

Seed command requires https://github.com/laravel/laravel/blob/9.x/database/seeders/DatabaseSeeder.php (and loading it)


$ wp acorn make:migration create_test_table

   INFO  Migration [database/migrations/2023_02_22_050437_create_test_table.php] created successfully.

$ wp acorn migrate:status

  Migration name ............................................................. Batch / Status
  2023_02_22_050437_create_test_table ............................................... Pending

$ wp acorn migrate

   INFO  Running migrations.

  2023_02_22_050437_create_test_table .............................................. 9ms DONE

Closes #119

@retlehs retlehs force-pushed the database-support branch 2 times, most recently from 803f446 to c447c5e Compare February 22, 2023 05:09
@retlehs retlehs changed the title 🚧 Database support ✨ Database support Feb 22, 2023
@retlehs retlehs requested a review from QWp6t February 22, 2023 05:09
@retlehs retlehs added the enhancement New feature or request label Feb 22, 2023
@retlehs retlehs marked this pull request as ready for review February 22, 2023 05:09
config/database.php Outdated Show resolved Hide resolved
@QWp6t
Copy link
Sponsor Member

QWp6t commented Feb 26, 2023

This introduces breaking changes in the console.

Someone can't update Acorn without running into issues in their console that are pretty difficult to recover. Since the console kernel crashes before fully booting, it's not possible run commands like acorn optimize:clear or acorn clear-compiled

image

The way to fix this is to conditionally load the command(s) added here. I will look into a solution that can be reused so we can more easily add support for other Laravel components without running into this problem.

@chrillep
Copy link
Contributor

chrillep commented May 25, 2023

Any progress with conditional loading?

I'd really like the factory and seeding from laravel.

Opens up a lot of automated testing opportunities that are pretty time consuming right now.

@chrillep
Copy link
Contributor

chrillep commented Jun 10, 2023

oh sry btw will this enable factories and models?
or is that a future PR? =).
nvm got it working. if i get the time maybe write tutorial or try and use https://github.com/TheDoctor0/laravel-factory-generator to create models and factories.

TablePlus has support for exporting a table as Laravel migration
https://journal.simondepelchin.be/2019/03/07/export-table-as-laravel-migration-in-tableplus/
https://github.com/tablePlus/tabledump
Skärmavbild 2023-06-10 kl  14 29 47

@chrillep
Copy link
Contributor

chrillep commented Jun 10, 2023

even better

composer require kitloong/laravel-migrations-generator --dev
wp acorn package:discover
wp acorn migrate:generate
composer require krlove/eloquent-model-generator --dev
wp acorn package:discover
wp acorn krlove:generate:models
composer require thedoctor0/laravel-factory-generator --dev
wp acorn package:discover
wp acorn generate:factory --recursive

or to just generate seeders from current db state

composer require orangehill/iseed --dev
wp acorn package:discover
wp acorn iseed <table_name>

Copy link
Sponsor Member

@QWp6t QWp6t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

@retlehs retlehs merged commit 172c7a3 into main Jun 13, 2023
3 checks passed
@retlehs retlehs deleted the database-support branch June 13, 2023 17:09
@chrillep
Copy link
Contributor

great news! good work @retlehs @QWp6t ❤️

@chrillep
Copy link
Contributor

chrillep commented Dec 7, 2023

i noticed corcel already had models for WP https://github.com/corcel/corcel/tree/7.0/src/Model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illuminate/database support?
3 participants