-
Notifications
You must be signed in to change notification settings - Fork 21
Fix: start up issue fixed #92
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import _sequelize from 'sequelize'; | ||
| const { Model, Sequelize } = _sequelize; | ||
|
|
||
| export default class DriverLocations extends Model { | ||
| static init(sequelize, DataTypes) { | ||
| return sequelize.define('DriverLocations', { | ||
| id: { | ||
| type: DataTypes.CHAR(36), | ||
| allowNull: false, | ||
| defaultValue: Sequelize.Sequelize.fn('uuid'), | ||
| primaryKey: true | ||
| }, | ||
| driverId: { | ||
| type: DataTypes.CHAR(36), | ||
| allowNull: false, | ||
| references: { | ||
| model: 'users', | ||
| key: 'id' | ||
| }, | ||
| field: 'driver_id' | ||
| }, | ||
| location: { | ||
| type: "POINT", | ||
| allowNull: false | ||
| } | ||
| }, { | ||
| tableName: 'driver_locations', | ||
| timestamps: true, | ||
| indexes: [ | ||
| { | ||
| name: "PRIMARY", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "idx_driver_locations_driver_id", | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "driver_id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "idx_driver_locations_location", | ||
| type: "SPATIAL", | ||
| fields: [ | ||
| { name: "location", length: 32 }, | ||
| ] | ||
| }, | ||
| ] | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import _sequelize from 'sequelize'; | ||
| const { Model, Sequelize } = _sequelize; | ||
|
|
||
| export default class OauthAccessTokens extends Model { | ||
| static init(sequelize, DataTypes) { | ||
| return sequelize.define('OauthAccessTokens', { | ||
| id: { | ||
| autoIncrement: true, | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true | ||
| }, | ||
| oauthClientId: { | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| references: { | ||
| model: 'oauth_clients', | ||
| key: 'id' | ||
| }, | ||
| field: 'oauth_client_id' | ||
| }, | ||
| accessToken: { | ||
| type: DataTypes.STRING(64), | ||
| allowNull: false, | ||
| unique: "oauth_access_tokens_access_token_uindex", | ||
| field: 'access_token' | ||
| }, | ||
| expiresIn: { | ||
| type: DataTypes.MEDIUMINT.UNSIGNED, | ||
| allowNull: false, | ||
| field: 'expires_in' | ||
| }, | ||
| expiresOn: { | ||
| type: DataTypes.DATE, | ||
| allowNull: false, | ||
| field: 'expires_on' | ||
| }, | ||
| metadata: { | ||
| type: DataTypes.JSON, | ||
| allowNull: false | ||
| } | ||
| }, { | ||
| tableName: 'oauth_access_tokens', | ||
| timestamps: true, | ||
| indexes: [ | ||
| { | ||
| name: "PRIMARY", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "oauth_access_tokens_access_token_uindex", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "access_token" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "oauth_access_tokens_oauth_clients_id_fk", | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "oauth_client_id" }, | ||
| ] | ||
| }, | ||
| ] | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import _sequelize from 'sequelize'; | ||
| const { Model, Sequelize } = _sequelize; | ||
|
|
||
| export default class OauthClientResources extends Model { | ||
| static init(sequelize, DataTypes) { | ||
| return sequelize.define('OauthClientResources', { | ||
| id: { | ||
| autoIncrement: true, | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true | ||
| }, | ||
| oauthClientId: { | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| references: { | ||
| model: 'oauth_clients', | ||
| key: 'id' | ||
| }, | ||
| field: 'oauth_client_id' | ||
| }, | ||
| resourceType: { | ||
| type: DataTypes.STRING(36), | ||
| allowNull: false, | ||
| field: 'resource_type' | ||
| }, | ||
| resourceId: { | ||
| type: DataTypes.STRING(36), | ||
| allowNull: false, | ||
| field: 'resource_id' | ||
| } | ||
| }, { | ||
| tableName: 'oauth_client_resources', | ||
| timestamps: true, | ||
| indexes: [ | ||
| { | ||
| name: "PRIMARY", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "oauth_client_resources_oauth_client_id_resource_uindex", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "oauth_client_id" }, | ||
| { name: "resource_type" }, | ||
| { name: "resource_id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "resource_type", | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "resource_type" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "resource_id", | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "resource_id" }, | ||
| ] | ||
| }, | ||
| ] | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import _sequelize from 'sequelize'; | ||
| const { Model, Sequelize } = _sequelize; | ||
|
|
||
| export default class OauthClientScopes extends Model { | ||
| static init(sequelize, DataTypes) { | ||
| return sequelize.define('OauthClientScopes', { | ||
| id: { | ||
| autoIncrement: true, | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| primaryKey: true | ||
| }, | ||
| oauthClientId: { | ||
| type: DataTypes.INTEGER, | ||
| allowNull: false, | ||
| references: { | ||
| model: 'oauth_clients', | ||
| key: 'id' | ||
| }, | ||
| unique: "oauth_client_scopes_oauth_clients_id_fk", | ||
| field: 'oauth_client_id' | ||
| }, | ||
| scope: { | ||
| type: DataTypes.STRING(36), | ||
| allowNull: false | ||
| } | ||
| }, { | ||
| tableName: 'oauth_client_scopes', | ||
| timestamps: true, | ||
| indexes: [ | ||
| { | ||
| name: "PRIMARY", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "id" }, | ||
| ] | ||
| }, | ||
| { | ||
| name: "oauth_client_scopes_uindex", | ||
| unique: true, | ||
| using: "BTREE", | ||
| fields: [ | ||
| { name: "oauth_client_id" }, | ||
| ] | ||
| }, | ||
| ] | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||||||||||||||||||||||||||||
| import _sequelize from 'sequelize'; | ||||||||||||||||||||||||||||||||
| const { Model, Sequelize } = _sequelize; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export default class OauthClients extends Model { | ||||||||||||||||||||||||||||||||
| static init(sequelize, DataTypes) { | ||||||||||||||||||||||||||||||||
| return sequelize.define('OauthClients', { | ||||||||||||||||||||||||||||||||
| id: { | ||||||||||||||||||||||||||||||||
| autoIncrement: true, | ||||||||||||||||||||||||||||||||
| type: DataTypes.INTEGER, | ||||||||||||||||||||||||||||||||
| allowNull: false, | ||||||||||||||||||||||||||||||||
| primaryKey: true | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| clientId: { | ||||||||||||||||||||||||||||||||
| type: DataTypes.STRING(320), | ||||||||||||||||||||||||||||||||
| allowNull: false, | ||||||||||||||||||||||||||||||||
| unique: "oauth_clients_client_id", | ||||||||||||||||||||||||||||||||
| field: 'client_id' | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| clientSecret: { | ||||||||||||||||||||||||||||||||
| type: DataTypes.STRING(36), | ||||||||||||||||||||||||||||||||
| allowNull: false, | ||||||||||||||||||||||||||||||||
| field: 'client_secret' | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| grantType: { | ||||||||||||||||||||||||||||||||
| type: DataTypes.ENUM('CLIENT_CREDENTIALS'), | ||||||||||||||||||||||||||||||||
| allowNull: true, | ||||||||||||||||||||||||||||||||
| field: 'grant_type' | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| }, { | ||||||||||||||||||||||||||||||||
| tableName: 'oauth_clients', | ||||||||||||||||||||||||||||||||
| timestamps: true, | ||||||||||||||||||||||||||||||||
| indexes: [ | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "PRIMARY", | ||||||||||||||||||||||||||||||||
| unique: true, | ||||||||||||||||||||||||||||||||
| using: "BTREE", | ||||||||||||||||||||||||||||||||
| fields: [ | ||||||||||||||||||||||||||||||||
| { name: "id" }, | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "oauth_clients_client_id", | ||||||||||||||||||||||||||||||||
| unique: true, | ||||||||||||||||||||||||||||||||
| using: "BTREE", | ||||||||||||||||||||||||||||||||
| fields: [ | ||||||||||||||||||||||||||||||||
| { name: "client_id" }, | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "client_id", | ||||||||||||||||||||||||||||||||
| using: "BTREE", | ||||||||||||||||||||||||||||||||
| fields: [ | ||||||||||||||||||||||||||||||||
| { name: "client_id" }, | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove redundant index on client_id. There's a redundant non-unique index {
name: "oauth_clients_client_id",
unique: true,
using: "BTREE",
fields: [
{ name: "client_id" },
]
},
- {
- name: "client_id",
- using: "BTREE",
- fields: [
- { name: "client_id" },
- ]
- },📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "client_secret", | ||||||||||||||||||||||||||||||||
| using: "BTREE", | ||||||||||||||||||||||||||||||||
| fields: [ | ||||||||||||||||||||||||||||||||
| { name: "client_secret" }, | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Make grantType a required field.
The
grantTypefield is currently nullable (allowNull: true), but this is typically a required field for OAuth clients as it determines the authentication flow. Consider making it required.grantType: { type: DataTypes.ENUM('CLIENT_CREDENTIALS'), - allowNull: true, + allowNull: false, field: 'grant_type' }📝 Committable suggestion