stablekernel / aqueduct

Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.
https://aqueduct.io
BSD 2-Clause "Simplified" License
2.4k stars 278 forks source link

Allow ORM and CLI to specify a database schema #664

Open insinfo opened 5 years ago

insinfo commented 5 years ago

how to use aqueduct with a pre-existing database with a specific schema.

I have several REST APIs, implemented in PHP with Slim Framework, and I am rewriting them in Aqueduct, but for this I need to use the same database and the same schemas, I did not find in the Aqueduct documentation how to use schemas, I saw that when I run an Aqueduct migration it creates the tables in the "Public" schema of the PostgreSQL database. How to select the "schema" from "Public" to "App1" for example

image

itsjoeconway commented 5 years ago

There is not currently a way to specify a database schema. I'll rewrite the title of this issue to reflect the ask.

axellebot commented 5 years ago

Hello, Are you working on it ? I'd like to participate :)

insinfo commented 5 years ago

There is not currently a way to specify a database schema. I'll rewrite the title of this issue to reflect the ask.

it is a pity that it is not possible to do this because I have many applications with many databases and I will not and I can not even redo them, I would like to port my applications that are in PHP more I see that there is still a lack of maturity in dart for this.

axellebot commented 5 years ago

@insinfo you may mixing language features with ORM framework/library features.

The framework itself might be imatture by its missing basics ORM features.

itsjoeconway commented 5 years ago

This feature isn't a high priority feature because you can recreate your schema and transfer the data over to a new database with a simple script. It is a lot easier to do this on a per-application basis than it is to try and build this feature into the framework, especially because the transfer is a one-time task. It's also incredibly complex to retrofit an arbitrary database into a managed ORM, and the value is simply not there to do that.

insinfo commented 5 years ago

"complex to retrofit an arbitrary database into a managed ORM"

I totally disagree, I work with several arbitrary databases with several php ORMs, such as Eloquent, Doctrine, ADOdb, Propel, and it was very easy to work with these ORMs out of the box, for example currently several of the projects I currently work on make use of Eloquent without Laravel, and some with Laravel.

itsjoeconway commented 5 years ago

Would you be able to take a crack at a proof of concept that fits your use cases? I can provide some guidance. General areas that need to be touched are:

Also, have you been able to use an ORM from a different language stack (e.g. Hibernate or Entity framework) than PHP on the same database? I wonder if they have any documentation/source on how they do it.

GregorySech commented 5 years ago

I've tried Eloquent with MySQL and Postgres but it should provide connectors for SQLServer and others, it works quite well as long as you do not do raw queries.

From what I've understood its ActiveRecord (Model) implementation is powered by a Query Builder interface and the ORM provides implementation for the principal dialects based on which connection is provided. If you are looking for source it should be here https://github.com/laravel/framework/tree/5.8/src/Illuminate/Database .

AFAIK Laravel schema migrations follow the same pattern however the framework does not offer any kind of automatic schema sync between a codified definition and an existing schema.

ps: Aqueduct is really dope however we cannot adopt it at work because we use MySQL a lot...

oldshen commented 4 years ago

i forked this project,and added MySQL database support,I hope it helps you,https://github.com/oldshen/aqueduct

Reductions commented 4 years ago

@oldshen Maybe you should rename schema to something else (flavor for example) as schema is database term is used for something else.

maurobotta commented 4 years ago

this project,and added MySQL database support,I hope it helps you,https:

great