[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
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

Code First Migration #85

Open
karamokoisrael opened this issue Jun 27, 2024 · 2 comments
Open

Code First Migration #85

karamokoisrael opened this issue Jun 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@karamokoisrael
Copy link

Hi,

The directus-sync extension is a valuable tool, but manipulating JSON directly can be cumbersome and lacks autocompletion for TypeScript users. To address this, I propose a TypeORM-inspired approach for data migration in Directus.

This feature would introduce specific decorators for TypeScript classes that inherit from a base class. This base class would have a method for serializing the model into a JSON file compatible with the directus-sync migration format. These decorators would provide autocompletion and type safety, streamlining the migration process.

I'm eager to contribute to this feature and would appreciate any guidance on ensuring compatibility with the current directus-sync implementation. I'm happy to discuss further details and explore the best approach for integration.

@EdouardDem
Copy link
Member

@karamokoisrael This is a great idea. I love it.

I think the most difficult part will be defining the type of the snapshot. There is a partial type here, but it doesn't cover all field types.

Nevertheless, this will be of great value for coders who prefer to define the structure of Directus with TypeScript rather than using the interface.

Initially, we can focus on the push and diff commands as they are the most valuable features and the most straightforward. As you said, we need to serialize the TypeScript objects to JSON and then use the tool as usual.

In the future, we can consider pulling the configuration into TypeScript format. This can be useful if coders want to manage an existing Directus instance from TypeScript. We could use TSMorph

The first step is to write the TypeScript definition of the configuration pulled from Directus (collections and snapshot). We can think about how to integrate this with the rest of the tool later.

@karamokoisrael
Copy link
Author
karamokoisrael commented Jun 30, 2024

Thanks for your guidance. I'll try to draft something locally and see if it works.

@EdouardDem EdouardDem added the enhancement New feature or request label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants