Comments (11)
You can access driver and its query builder via connection object and via connection manager. If you have complexities with it, I recommend you to use native driver (or easiest for you). Migration support is something that is next in my plan and Im planning to ship it this month.
from typeorm.
totally needed feature, one of the most complex that is left. Im still thinking what is the best way to organize this process. @19majkel94 do you have experience using migrations in other orms, how they look like and what is the best approach?
from typeorm.
Oh, unfortunately not yet, I'm a beginner with no big experience - I just like new, good languages/frameworks/tools 😉 I even don't get the migration concept well so I'm not able to help you with this feature.
from typeorm.
Have you considered using umzug from Sequelize? It allows for a fast integration of up() and down() functions executed consecutively and log which migration ran. Only that as DB it integrates with Sequelize or a JSON file log.
from typeorm.
its easy to implement something that runs up and down functions... The problem is that users will do inside them... Will they write raw sql code there? Or should orm provide good api to write migrations? Or should orm generate migrations by itself if its possible? Or anything else?
from typeorm.
I was thinking more of a first minimum working version that can be used for producing the models and it's changes maybe with a few predefined queries like createColumn(), dropColum(), and or just raw queries.
For me the ideal TS ORM shall resemble and improve what EntityFramework offers in C# world. But that seems like a big endeavour even though you're half the way into it.
What I found lacking in Javascript ORMs is general scaffolding/self migration generation, nice clean models, and annotation based enrichment. As I mentioned I think typeorm is changing this and I found it resemblant to EntityFramework in it's way of creating models and querying.
Never the less, as you already found a way of tracking changes of the models vs DB and writing SQL to reflect those changes, it would be a first step to encapsulate that SQL into a migration/file and run it from command line.
Even EF haven't offered a de-facto way of using their models into it's generated migrations, that's an improvement I would recommend after a working basic scheme migration. It may be straight away to make or not.
from typeorm.
I think Raw SQL is acceptable at first time. While generated migration script is sometimes unreliable.
from typeorm.
agree. you can use some third party package for example db-migrate until I implement this. If of course nobody want to contribute :)
from typeorm.
Hi there again!
I was wondering how to implement a first self-generated script using your SchemaBuilder @pleerock . Reading the code related to SchemaBuilder, then QueryBuilder and come to think that if we can inject a string writer/array writer class every time query() is called (at least in MysqlQueryRunner) instead of using a native connection to the Database Driver, we could get the SQL statements to insert into an scaffold up() function.
Maybe an extension to the native connection and allowing in MysqlDriver to overwrite it's databaseConnection with a provided connection class in the constructor.
It goes beyond my understanding of the code(and sadly my available time) how to inject such class and discriminate the schema checking queries needed to generate the change queries(use a regex discriminating SELECTs?) and intercept only the later triggered in a cli based tool.
from typeorm.
implemented in #120 need your feedback guys
from typeorm.
added docs here and updated example how to use it. released in 0.0.5
from typeorm.
Related Issues (20)
- Postgres geometry column is always being altered to type geometry in every migration despite already being type geometry
- QueryFailedError: read ECONNRESET HOT 7
- Using transactions in tests w/ NestJS & TypeORM
- QueryBuilder looks up the wrong joinAttr when entities have identical property names
- Simple SQL statement generation with Repository object
- SSL AMAZON RDS HOT 2
- typeorm Not Compatible with Latest Version of Mongo HOT 1
- Can not generate migrations with capacitor driver: "Cannot use import statement outside a module"d HOT 1
- No metadata for "book" was found.
- Cascade save on 1 to 1 relations HOT 1
- Switching to esnext - fields not part of "select" are returned with "undefined"
- (B)LOB streaming
- Upsert with generated columns
- Returntype for find() using FindOneOptions and relations
- Invalid use of take in MySQL
- Retrieving additional relationships after an entity has been retrieved and instantiated seems an obvious, useful and easy feature to implement.
- Add support for better-sqlite3 v10
- Property metadata override does not work when extending an entity class
- Why did timezone become `SYSTEM` HOT 1
- format code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm.