-
Notifications
You must be signed in to change notification settings - Fork 3
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
[question]: How can I create migrations with an index that is a Number #10
Comments
I'm not sure if the underlying OneTable supports that use case either. Does OneTable work for you in that case? It looks like OneTable expects the MigrationModel to have a string sort key. |
OneTable Works in 90% of my use cases, but it would be useful to have the flexibility to configure the Migration Model. I had a look in the code: https://github.com/sensedeep/dynamodb-onetable/blob/main/src/Schema.js#L154-L172 createMigrationModel() {
let { indexes } = this;
let primary = indexes.primary;
let fields = (this.migrationModelFields = {
[primary.hash]: { type: 'string', value: `${MigrationKey}` },
date: { type: 'date', required: true },
description: { type: 'string', required: true },
path: { type: 'string', required: true },
version: { type: 'string', required: true },
status: { type: 'string' },
});
if (primary.sort) {
fields[primary.sort] = { type: 'string', value: `${MigrationKey}:\${version}:\${date}` };
}
this.models[MigrationModel] = new Model(this.table, MigrationModel, { fields, indexes });
} Correct me if I am wrong, but it looks like the migration model does not need a sort key to function. So perhaps we could have a configuration to omit it? Then it wouldn't matter if I had a Numeric sort key. |
It would depend on if migration and the cli modules are using the SK to query migrations by version or not. If they are getting the migrations list and using the version and date properties, it may work. If they are constructing queries and constructing the SK manually, then it would not. Feel free to hack and try. Would be a good use case to add. |
I have a schema:
My IaC code also defines this table:
But OneTable Migrate wants to create:
So I will end up getting an error:
Is is possible to have the _Migration model created on a GSI instead? Is there anything I can do to make migrations work given a String/Number Hash/Sort?
The text was updated successfully, but these errors were encountered: