-
Notifications
You must be signed in to change notification settings - Fork 56
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
(dev/core#4999) Support Entity Framework v2 for extensions #331
Conversation
Nice! @totten don't let this be a blocker but just wondering if the upgrade scenario has been considered? Where a new entity is added to already installed extension and needs to install that entity on upgrade. Maybe there is a function we can call from the upgrader? |
I agree this would be beneficial. In the upgrade scenario you can't just read from the current schema and add that table as-is, because the table might change in the future, so your upgrader has to provide a snapshot of the table structure as it first appears. And we do want to leverage the goodness of the auto-detect-collation here. So a utility function would be great that you can feed in a table definition as an array and it spits out the |
Thanks, good points about upgrading @mattwire @colemanw. (Aside: I got so far into the rabbit of hole of "how to polyfill an upgrader class" that I kind of stopped thinking about the design of the upgrader-class being delivered...) Probably the most direct thing is like you say -- add a helper function. It feels like this means switching the class-relationship.
(I agree that adding the specific helper function probably shouldn't be a blocker. I'm not certain if it's easy or hard. But there should be a clear place to put that kind of helper.) FWIW.... there's almost enough information to do updates like I guess you could unify the sequences. Values like I dunno, that sounds a little radical. For the moment, probably better to think about how to add helper function. |
... or to keep it very explicit: |
7f93601
to
f47e96b
Compare
I've pushed a set of updates (but haven't updated description yet). Basically:
|
f47e96b
to
c769231
Compare
civibot, test this please |
So I rebased and switched this from the unreleased
|
@totten what's the status of this? |
@totten I've just finished converting the rest of our core extensions to use this. |
516ed6a
to
a5ecaad
Compare
Ah, blerg. There's a test-interaction problem (i.e. tests pass individually but fail in bulk). E2E tests look like this: $this->civixGenerateModule(static::getKey(), [
'--compatibility' => '5.69',
]);
$this->civixGenerateUpgrader();
$this->civixGenerateEntity('Bread');
$this->civixGenerateEntity('Sandwich');
tldr: I need a separate PR to change the testing process. |
5778108
to
4931342
Compare
a9966a7
to
e459b65
Compare
…plement with addClass()
If you're not making the file, then you don't need to make the folder...
6d99fa8
to
1d5954b
Compare
Fixed a "WIP" commit that was outstanding. We had a clean test-run. I also did some local trials like this:
I also went back and re-tried Hopefully (knocks on wood) test-suites will still be happy... |
…essary, use backport. Sometimes, when it's taking forever, you need to get a hammer.
e333b71
to
feb5fb5
Compare
feb5fb5
to
da7109d
Compare
FIXME: Upgrade/convert step also needs to generate skinny DAOs. |
9279596
to
ed3c5b2
Compare
ed3c5b2
to
5a578e6
Compare
The upgrade/convert step will now re-generate DAOs -- and delete the old XML schema files. Unless the test-suite has some complaints with this revision, then I think the PR may be ready to merge.... |
Looks good @totten As you probably remember, my vision is for these thin DAOs to be temporary, and as the core EntityRepository matures, the API will switch to calling |
Overview (Final)
Implement support for Entity Framework v2 (EFv2; aka dev/core#4999). This is a general overhaul of everything related to
generate:entity
. There's a more complete comparison of changes at: https://github.com/totten/civix/wiki/Entity-TemplatesThe PR was originally opened to address one major sub-problem (installation and SQL generation). I'm preserving that description so that the discussion remains intelligible. However, the ultimate scope of the PR evolved to cover more aspects of dev/core#4999 / EFv2. The wiki page gives a more comprehensive summation.
(Subject: Auto-generate SQL during installation via
[email protected]
)Overview (Original)
For extensions that use
generate:entity
/generate:entity-boilerplate
, this changes the SQL lifecycle:auto_install.sql
andauto_uninstall.sql
).ping @colemanw @mattwire @artfulrobot @christianwach
Before
civix generate:entity-boilerplate
readsxml/schema/**.xml
and generates SQL files (sql/auto_install.sql
andsql/auto_uninstall.sql
).utf8
vsutf8mb4
).After
During installation, we call a new helper class
CiviMix\Schema\Automatic\MyModule
CustomGroup
s.civicrm-core
and backported viacivix
. As with mixins, it will check the<compatibility>
when deciding whether a backport is needed. At runtime, it will look to core-code and extension-code and choose the newest version.civix generate:entity-boilerplate
does not generate SQL files.civix upgrade
will prompt you to apply the following changesOld screenshotRelated PRs
mosaico.git
with (Draft) Installer - Auto-generate SQL to match local schema veda-consulting-company/uk.co.vedaconsulting.mosaico#635TODO
generate:upgrader
should set<upgrader>CiviMix\Schema\Automatic\MyModule</upgrader>
.civix.phar
. (I've been testing local git copy.)