PinguApps / AppwriteMigrator

PinguApps.AppwriteMigrator is a .NET CLI tool that enables a code-first approach to managing your database schema with Appwrite. This tool simplifies the process of syncing and migrating your database schema between local and remote environments, ensuring consistency across development, staging, and production setups.
MIT License
10 stars 0 forks source link

[Question] Does it only migrate schema or also the documents in the collection? #37

Open bigraymasoom opened 3 months ago

bigraymasoom commented 3 months ago

Question

I was curious to know if this tool also migrate documents along with collections.

Additional Context

No response

pingu2k4 commented 3 months ago

Hey! The purpose of this tool is to migrate the schema only - documents will be left where they are.

Moving documents about is something that is already supported by Appwrite CLI, with the caveat that it will wipe all existing data.

I build this tool to allow the migration of schema, so that you can make incremental updates to your schema from environment to environment, without loss of data in said environment.

bigraymasoom commented 3 months ago

Thanks a lot it helped me a lot a lot. One issue I am facing is that only first 25 collections are migrated to the new instance for all the databases.

pingu2k4 commented 3 months ago

No problem. :)

The issue you mention in latest comment - is that with this tool, or with the Appwrite CLI?

bigraymasoom commented 3 months ago

Tool

pingu2k4 commented 3 months ago

Hmm, I haven't had that many collections personally so haven't tested it... Docs on Appwrite don't mention a max limit of collections returned that I could see, or any sort of paging information...

I will check it out...

bigraymasoom commented 3 months ago

Default limit is 25 if you don't pass limit query.

pingu2k4 commented 3 months ago

I'll look into sorting this :)

pingu2k4 commented 3 months ago

Default limit is 25 if you don't pass limit query.

I've made a fix for this, but am unable to test it properly currently. 0.1.3-alpha is available on nuget and should resolve this for you, let me know if it works or not :)

bigraymasoom commented 3 months ago

Will test today and share the results. Thanks. It will be even perfect if you add a way for migrating documents in collections because appwrite CLI also only supports collections and databases not documents. Again thanks, will test today

bigraymasoom commented 3 months ago

Collections were successfully created but attributes creation error after creating some attributes.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Appwrite.Models.AttributeString.From(Dictionary2 map) at Appwrite.Client.Call[T](String method, String path, Dictionary2 headers, Dictionary2 parameters, Func2 convert) at PinguApps.AppwriteMigrator.AppwriteCommands.CreateAttribute(Databases dbClient, Attribute attribute, String databaseId, String collectionId) in /home/runner/work/AppwriteMigrator/AppwriteMigrator/src/PinguApps.AppwriteMigrator/AppwriteCommands.cs:line 351 at PinguApps.AppwriteMigrator.AppwriteCommands.Migrate(String endpoint, String projectId, String apiKey, String fileName) in /home/runner/work/AppwriteMigrator/AppwriteMigrator/src/PinguApps.AppwriteMigrator/AppwriteCommands.cs:line 231 at Cocona.Command.Dispatcher.Middlewares.CoconaCommandInvokeMiddleware.DispatchAsync(CommandDispatchContext ctx) at Cocona.Command.Dispatcher.Middlewares.HandleParameterBindExceptionMiddleware.DispatchAsync(CommandDispatchContext ctx) at Cocona.Command.Dispatcher.Middlewares.HandleExceptionAndExitMiddleware.DispatchAsync(CommandDispatchContext ctx)

pingu2k4 commented 3 months ago

Hm, not sure why that would be happening...

Immediately before the error there should be some console output... Specifically I would be looking for a line immediately before saying Creating Attribute {attribute.Key}... with the obvious replacement...

If you are able to identify the attribute that its referencing, and find it in the source database (or the schema file that it created when running the sync command), that would be super useful and allow me to debug it further. :)

bigraymasoom commented 3 months ago

Sure will share soon.