I am converting any of the business apps that were started in WO to Swift.. What an experience. (Or maybe I am just late to the party!)
I would love to hear that there are others that are using Swift/Vapor/Fluent and if any of this helps. Years ago, when I first looked at Swift, the first thing I saw was how it was structured like WebObjects. But, at that time the only choice was to use local databases (CoreDate?). So, I kind of ignored Swift and waited. In today’s world, you have Swift with Vapor and Fluent (ORM) and things look interesting. I have a problem. There is no EOModeler. You must create your Model in code one entity at a time. I even asked my girlfriend (Claude) why there was no EOModeler as in WO. swift-Vapor question: Why is there no OBJECT Modeler like we have in WebObjects: EOModeler? Claude: There's no EOModeler equivalent for Vapor mainly because the server-side Swift world, like most of the industry, chose code-first modeling. A graphical modeler doesn't fit that approach well. 1. In Fluent, the model is the Swift code. 2. Model files were painful to version-control. 3. Even Apple moved away from it. 4. Fluent is much thinner than EOF. 5. It's a small open-source project that runs on Linux. A good cross-platform GUI modeler is a lot of work. The Vapor core team has always spent its effort on the framework itself. In short, EOModeler belonged to a runtime-metadata design. Swift's type system and the move to code-first workflows replaced that model file with source code. This does not seem correct so I came back with: I re-read your reply when I asked if there existed a 'Modeler' app. you gave some compelling arguments for not having this app. However, after much debate and soul-searching, I still disagree. The tool is not for the complete creation of the model. it is used to create the foundation and ideation of the project. How do the entities interact? You are suggesting that the project (Entities and attributes) are known and understood BEFORE the project starts. So, just type what is in your mind. Just like a sculptor can look at a big marble block and clear away the extraneous rock to reveal David! The start of the project IS the creation and ideation of the Model. The OrchestraBooking app went so easily because the Model was so well defined. I have been trying to imagine if using CayenneModeler could help as it is a stand alone app. Or if starting a Swift app really requires starting it as a WO app and using that as the basis. Well, we know we are in trouble when your girlfriend/wife/SO says those magic words: “You’re right! and I made a mistake ” Claude: You're right, and I made a mistake in my earlier answer. I treated two different jobs as one. The modeler as source of truth at runtime. EOF loaded the .eomodeld while the app was running. Swift has moved away from this, and that's the job my arguments were about. The modeler as a thinking tool. You lay out entities, draw relationships, and see a many-to-many stand out before you've written any code. Code-first doesn't replace this. Typing @Siblings(through:from:to:) is a poor way to discover that Musician and Engagement need a join entity. Your OrchestraBooking experience supports this: when the model has been thought through, the code goes quickly. So the real gap in the Swift world is a design tool that hands off to code, not a runtime model file. That gap can be filled. CayenneModeler is a good fit It's a reasonable choice: It runs on its own. It's a Java desktop app, so it doesn't need Eclipse or a WO project. Its ideas match EOModeler's. Cayenne grew from the same ideas as EOF, so you'll recognize entities, attributes, relationships, and flattened many-to-many relationships through a join entity. Its output is easy to read. The DataMap is saved as a .map.xml file listing every entity, attribute, type, and relationship. It can reverse-engineer an existing database, so it also works as a viewer. The missing piece is a generator: a small program that reads the .map.xml and writes the Fluent model classes and a migration. The mapping is mostly direct: Cayenne Fluent ObjEntity final class X: Model attribute @Field / @OptionalField to-one relationship @Parent / @OptionalParent to-many relationship @Children flattened many-to-many pivot model + @Siblings on both sides DbEntity + columns CreateX: AsyncMigration The workflow would then be: think in CayenneModeler → generate → write migrations by hand from then on. You don't need to start as a WO app Starting from WebObjects isn't necessary. If you prefer Entity Modeler in WOLips because you already know it, that works the same way. An .eomodeld is a folder of plist files, which are just as easy to parse. Either way, the modeler is only the drawing board. The Swift project never depends on it. One caution on round-tripping Generating once at the start is simple and reliable. Keeping the visual model and the Swift code in sync for the life of the project is much harder. Once you hand-edit models and add migrations, the generated diagram and the code drift apart. For an ongoing picture, regenerate a diagram from the database rather than editing the model back. If you'd like, I can write that generator. Send me (or attach) a .map.xml or .eomodeld, even a small sample from OrchestraBooking, and I'll build a script that turns it into Fluent models, pivot models, and an initial migration. here is the original .eomodeld The output looks right. One small fix: the cascade section should name the parent entity rather than saying "the parent". Then I'll check the diagram and the UUID variant. I wrote eomodel2fluent.py and ran it on your Booking model. The ZIP contains the script and everything it generated. What the generator does: Plain entities become Fluent models. Column names stay the same, and nullability is taken from allowsNull. Each to-one relationship becomes @Parent, or @OptionalParent if it can be empty, and each to-many becomes @Children. Your many-to-many relationships are recognised from their join entities. EventPerson, InstrumentBook, PersonInstrument and PersonShow become pivots. PersonBook becomes a pivot that also carries isPrimaryPlayer. Each pivot gets @Siblings on both sides, so you can use person.$shows, book.$people and so on, along with the original personShows-style relationships. EventBook links three entities (Book, Event and an optional Person). It's kept as a normal model, because it's really an assignment record rather than a simple link between two entities. Migrations are numbered M001_CreateShow to M014_CreatePersonShow, in foreign-key order. Each has an explicit name, and configure-migrations.swift holds the ordered list. This is the "Migration01, 02, 03" layout you were missing. Your EOF delete rules are carried over. The Cascade relationships on Book and Event become ON DELETE CASCADE. The unique login_idx on Person becomes a unique constraint. Booking.mmd is an ER diagram of the whole model. It renders in Mermaid-aware tools, and on GitHub you can paste it into a ```mermaid block. Decisions to check: Keys and booleans. I kept integer IDs and mapped intBoolean to Bool. For a fresh Vapor project, run it with --ids uuid instead. To read your existing showbooking database without changing it, use --int-booleans and don't run the create migrations, because the tables already exist. Instead, review and run use-existing-database.sql. It points each id at EOF's <table>_seq sequence so Fluent can insert rows. Check that those sequence names exist in your database first. Duplicate links. I added a unique-pair constraint to each pivot, so a person can't be linked to the same show twice. That wasn't in your EOModel, so delete that line in a migration if duplicates are intended. What isn't carried over. EOF optimistic locking, the Wonder ERXAuditKeys and ERXCopyable settings, and the .fspec fetch specifications have no Fluent equivalent. REPORT.md lists them. Not tested: there's no Swift compiler here, so I haven't built the generated Swift. I checked it carefully against the Fluent 4 API. If swift build reports anything, send me the errors. Two things in the model are worth fixing while you're moving it over. Person.password is a plain varchar, so plan to store a Bcrypt hash; Vapor has Bcrypt built in. ShowTime.startTime is stored as text rather than a time. To use this as a design step, model or change entities in Entity Modeler, then run: python3 eomodel2fluent.py Booking.eomodeld -o Generated Use it to start projects. After the first migration has run, add later changes by hand as new migrations, as we discussed.
