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

[WIP] Add migration support for sqlite, better validation #4

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

cameronblandford
Copy link
Collaborator

No description provided.

Copy link
Member

@JeffSpies JeffSpies left a 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;
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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) {
Copy link
Member

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");
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants