{"id":20757230,"url":"https://github.com/vapor-community/vii","last_synced_at":"2025-08-04T21:44:40.213Z","repository":{"id":104074545,"uuid":"233468160","full_name":"vapor-community/Vii","owner":"vapor-community","description":"Vii attempts to reverse engineer an existing database into Vapor 4 compatible models","archived":false,"fork":false,"pushed_at":"2020-02-29T16:48:46.000Z","size":123,"stargazers_count":7,"open_issues_count":7,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-29T09:56:21.144Z","etag":null,"topics":["database-schema","reverse-engineering","swift","vapor"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vapor-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-12T22:26:55.000Z","updated_at":"2024-06-05T07:41:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"aaad621e-605a-41d5-9a8a-2c58ef216054","html_url":"https://github.com/vapor-community/Vii","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2FVii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2FVii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2FVii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2FVii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vapor-community","download_url":"https://codeload.github.com/vapor-community/Vii/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251480069,"owners_count":21596016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-schema","reverse-engineering","swift","vapor"],"created_at":"2024-11-17T09:41:01.552Z","updated_at":"2025-04-29T09:56:26.892Z","avatar_url":"https://github.com/vapor-community.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![test](https://github.com/vapor-community/Vii/workflows/test/badge.svg) [![Code Coverage](https://codecov.io/gh/vapor-community/Vii/branch/master/graph/badge.svg)](https://codecov.io/gh/vapor-community/Vii) ![GitHub](https://img.shields.io/github/license/vapor-community/Vii)\n\n# Vii\n\n### Currently in pre-alpha\n\nExtensive changes to fluent currently in progress\n\nVii is a code generation tool loosely based on Gii from the [Yii](https://github.com/yiisoft/yii2) framework. Vii can quickly reverse engineer a database schema into [Vapor 4](https://github.com/vapor) compatible class definitions, including matching SQL data types to Swift equivalents. Currently, Vii supports Postgres and MySQL. \n\n## Installation\nTo start using Vii, clone the repo\n\n```swift\ngit clone https://github.com/vapor-community/Vii\n```\n\n## Usage\ncd into the directory of the recently cloned git repo and run the following command.\n\nThe basic command is\n```swift\nswift run Vii \u003cdatabase specifier\u003e\n```\n\nThere are two current options, `postgres` and `mysql`. \nSo to use with Postgres DB.\n\n```swift\nswift run Vii postgres\n```\n\n## Property Wrappers\nThe following lists the property wrappers that are currently implemented\n\n## @ID\nAny column idenitifed as a `Primary Key` is mapped to the `@ID` property wrapper.\n\n## @Field\nUnspecialized columns are mapped to the `@Field` property wrapper.\n\n## @NestedField\nColumns declared as `json` are mapped into the  `@NestedField` property wrapper. Vii does not analyze the content of columns, so it is unable to infer the structure of the json. Vapor requires this to be declared. Vii will automatically declare the property of type `UnMappedType`. The user should then replace this declaration with a more fitting one.\n\n## @CompoundField\nVii cannot infer this from a simple scan of the database. Again, the user would have to declare this property type manually\n\n## @Timestamp\nVapor's `@Timestamp` propertyWrapper uses an enum called `Trigger` which helps Fluent determine whether to update this column on creation, update or deletion. Because this is not derivable from the database columns directly, Vii makes an educated guess on what case to apply to the timestamp, this is done based on the column name.\n\n## Initializing Optional Model Properties\nAny property that is potentially `Null` in the database will be made optional in the model definition. The initializer's signature will apply them directly as `nil`, rather than omit them eg\n```swift\ninit(id: Int? = nil...)\n```\n\nVii will generate all the models in the specified DB and produce an output folder within the project\n\n### To Implement\n- Implement a swift formatter to remove the visual ugliness of escape sequences and make tests and everything else more friendly\n- Allow subsection of schema tables to be generated\n- Allow skip command to omit comma separated list of tables\n- Further support for `@propertyWrappers` as currently not all are implemented and some maybe very hard to implement robustly. I'm looking at you `@Sibling`\n- Makes sense to add migrations to the model so users could use their own test DB\n- Improved Github workflows to test DBs on Linux with small seeded DB\n\n### Future features\n- Look to hook a CRUD builder into it, so you can build standard end points and user repositories\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fvii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvapor-community%2Fvii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fvii/lists"}