added migrate script, extended schema, error handling