-
Notifications
You must be signed in to change notification settings - Fork 0
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
[WIP] Add migration support for sqlite, better validation #4
base: master
Are you sure you want to change the base?
Conversation
… feature/migrations
…to-knex into feature/migrations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll run tests tomorrow.
@@ -55,9 +56,15 @@ const types = { | |||
}, | |||
uuid: (table, name) => { | |||
return table.uuid(name); | |||
}, | |||
foreign: (table, name, options) => { | |||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still working on this?
async function createColumn(table, column, alter = false) { | ||
const columnName = column.name; | ||
// e.g., id: { type: "increments" } | ||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More....
const tableName = tableConfig.name; | ||
chain = createTable(chain, tableName, tableConfig); | ||
}); | ||
chain = await createTable(chain, tableName, tableConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the await necessary here?
* Adds the new schema to the migrations table and applies the relevant database changes to the rest of the db | ||
* @param {*} schema | ||
*/ | ||
async addMigration(schema) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this logic need to be contained in a transaction?
* @param {JSON} newSchema | ||
*/ | ||
function getColumnsToRemove(oldSchema, newSchema) { | ||
return _.differenceBy(oldSchema.columns, newSchema.columns, "name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to use a json diffing library here? I suppose we don't need much functionality here.
}); | ||
|
||
// get the resulting schema | ||
// TODO: this might not be necessary, could just use the schema obj passed into the method instead of newSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the schema object has been validated (and default values imputed?), then probably not necessary.
No description provided.