-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add groups and permissions for authorization (#6)
* 🧑💻 Add scripts for linting and building * ✨ Define createdAt and updatedAt aliases * 🗃️ Add auth group and permission tables * 🚚 Move query directory into db directory * 📌 Pin Bun to v1.1.12 in CI environment * 👷 Add build stage to CI pipeline
- Loading branch information
Showing
17 changed files
with
684 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
build | ||
|
||
.env | ||
.volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist | ||
|
||
node_modules | ||
build | ||
|
||
.volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,7 @@ export default tseslint.config( | |
], | ||
}, | ||
}, | ||
{ | ||
ignores: ['node_modules/', 'build/', '.volume/'], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { int, timestamp } from 'drizzle-orm/mysql-core' | ||
|
||
export const id = int('id').primaryKey().autoincrement() | ||
|
||
// No need to worry about the Y2K38 problem if you are using 64-bit versions of | ||
// platforms and MySQL 8.0.28 or later. | ||
export const createdAt = timestamp('created_at').notNull().defaultNow() | ||
export const updatedAt = timestamp('updated_at') | ||
.notNull() | ||
.defaultNow() | ||
.onUpdateNow() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE `auth_user` RENAME COLUMN `signup_date` TO `created_at`;--> statement-breakpoint | ||
ALTER TABLE `auth_user` MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT (now());--> statement-breakpoint | ||
ALTER TABLE `auth_user` ADD `updated_at` timestamp DEFAULT (now()) NOT NULL ON UPDATE CURRENT_TIMESTAMP; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CREATE TABLE `auth_group` ( | ||
`id` int AUTO_INCREMENT NOT NULL, | ||
`name` varchar(128) NOT NULL, | ||
CONSTRAINT `auth_group_id` PRIMARY KEY(`id`), | ||
CONSTRAINT `auth_group_name_unique` UNIQUE(`name`) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `auth_group_permission` ( | ||
`group_id` int NOT NULL, | ||
`permission_id` int NOT NULL, | ||
CONSTRAINT `auth_group_permission_group_id_permission_id_pk` PRIMARY KEY(`group_id`,`permission_id`) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `auth_permission` ( | ||
`id` int AUTO_INCREMENT NOT NULL, | ||
`name` varchar(128) NOT NULL, | ||
`code` varchar(128) NOT NULL, | ||
CONSTRAINT `auth_permission_id` PRIMARY KEY(`id`), | ||
CONSTRAINT `auth_permission_code_unique` UNIQUE(`code`) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `auth_user_group` ( | ||
`user_id` int NOT NULL, | ||
`group_id` int NOT NULL, | ||
CONSTRAINT `auth_user_group_user_id_group_id_pk` PRIMARY KEY(`user_id`,`group_id`) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `auth_user_permission` ( | ||
`user_id` int NOT NULL, | ||
`permission_id` int NOT NULL, | ||
CONSTRAINT `auth_user_permission_user_id_permission_id_pk` PRIMARY KEY(`user_id`,`permission_id`) | ||
); | ||
--> statement-breakpoint | ||
ALTER TABLE `auth_group_permission` ADD CONSTRAINT `auth_group_permission_group_id_auth_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `auth_group`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE `auth_group_permission` ADD CONSTRAINT `auth_group_permission_permission_id_auth_permission_id_fk` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE `auth_user_group` ADD CONSTRAINT `auth_user_group_user_id_auth_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `auth_user`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE `auth_user_group` ADD CONSTRAINT `auth_user_group_group_id_auth_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `auth_group`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE `auth_user_permission` ADD CONSTRAINT `auth_user_permission_user_id_auth_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `auth_user`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint | ||
ALTER TABLE `auth_user_permission` ADD CONSTRAINT `auth_user_permission_permission_id_auth_permission_id_fk` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission`(`id`) ON DELETE no action ON UPDATE no action; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "mysql", | ||
"id": "ab101c32-dd97-48ad-97d6-c3c797b2914b", | ||
"prevId": "a824d5e5-dff7-4abc-8eaf-6a4f119cafa3", | ||
"tables": { | ||
"auth_user": { | ||
"name": "auth_user", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "int", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": true | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "(now())" | ||
}, | ||
"updated_at": { | ||
"name": "updated_at", | ||
"type": "timestamp", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"onUpdate": true, | ||
"default": "(now())" | ||
}, | ||
"password": { | ||
"name": "password", | ||
"type": "varchar(128)", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"nickname": { | ||
"name": "nickname", | ||
"type": "varchar(32)", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"email": { | ||
"name": "email", | ||
"type": "varchar(255)", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": { | ||
"auth_user_id": { | ||
"name": "auth_user_id", | ||
"columns": ["id"] | ||
} | ||
}, | ||
"uniqueConstraints": { | ||
"auth_user_nickname_unique": { | ||
"name": "auth_user_nickname_unique", | ||
"columns": ["nickname"] | ||
}, | ||
"auth_user_email_unique": { | ||
"name": "auth_user_email_unique", | ||
"columns": ["email"] | ||
} | ||
} | ||
} | ||
}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": { | ||
"\"auth_user\".\"signup_date\"": "\"auth_user\".\"created_at\"" | ||
} | ||
} | ||
} |
Oops, something went wrong.