Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 21afc74

Browse files
committed
using the new mysql features from sugar
1 parent bf56366 commit 21afc74

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Sources/AdminPanel/Models/BackendUsers/BackendUser.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ public final class BackendUser: Auth.User, Model {
113113
table.timestamps()
114114
}
115115

116-
//role should be foreign key
116+
try database.driver.raw(database.foreign(parentTable: "backend_user_roles", parentPrimaryKey: "slug", childTable: "backend_users", childForeignKey: "role"))
117+
118+
try database.driver.raw(database.index(table: "backend_users", column: "email"))
117119
}
118120

119121
public static func revert(_ database: Database) throws {

Sources/AdminPanel/Models/BackendUsers/BackendUserResetPasswordTokens/BackendUserResetPasswordTokens.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public final class BackendUserResetPasswordTokens: Model {
7070
table.datetime("expire_at", optional: true)
7171
table.timestamps()
7272
}
73+
74+
try database.driver.raw(database.index(table: "backend_reset_password_tokens", column: "email"))
75+
try database.driver.raw(database.index(table: "backend_reset_password_tokens", column: "token"))
7376
}
7477

7578
public static func revert(_ database: Database) throws {

Sources/AdminPanel/Models/BackendUsers/BackendUserRoles/BackendUserRole.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public final class BackendUserRole: Model {
5959
table.bool("is_default");
6060
table.timestamps()
6161
}
62+
63+
try database.driver.raw(database.index(table: "backend_user_roles", column: "slug"))
6264
}
6365

6466
public static func revert(_ database: Database) throws {

0 commit comments

Comments
 (0)