From dfe40f760f982132af4f536b338092906909e8a0 Mon Sep 17 00:00:00 2001 From: sundayenglish Date: Fri, 20 Jun 2025 11:01:03 +0700 Subject: [PATCH] Add Migration File For Passport --- README.md | 4 ++ ...0_035901_create_oauth_auth_codes_table.php | 39 +++++++++++++++++ ...35902_create_oauth_access_tokens_table.php | 41 ++++++++++++++++++ ...5903_create_oauth_refresh_tokens_table.php | 37 ++++++++++++++++ ...6_20_035904_create_oauth_clients_table.php | 42 +++++++++++++++++++ ...035905_create_oauth_device_codes_table.php | 42 +++++++++++++++++++ 6 files changed, 205 insertions(+) create mode 100644 database/migrations/2025_06_20_035901_create_oauth_auth_codes_table.php create mode 100644 database/migrations/2025_06_20_035902_create_oauth_access_tokens_table.php create mode 100644 database/migrations/2025_06_20_035903_create_oauth_refresh_tokens_table.php create mode 100644 database/migrations/2025_06_20_035904_create_oauth_clients_table.php create mode 100644 database/migrations/2025_06_20_035905_create_oauth_device_codes_table.php diff --git a/README.md b/README.md index da9eb3e..ce0133d 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,7 @@ docker-compose up -d --build composer install --ignore-platform-reqs npm install ``` +### 5. Generate application key +```bash +php artisan key:generate +``` diff --git a/database/migrations/2025_06_20_035901_create_oauth_auth_codes_table.php b/database/migrations/2025_06_20_035901_create_oauth_auth_codes_table.php new file mode 100644 index 0000000..c700b50 --- /dev/null +++ b/database/migrations/2025_06_20_035901_create_oauth_auth_codes_table.php @@ -0,0 +1,39 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->index(); + $table->foreignUuid('client_id'); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_auth_codes'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/database/migrations/2025_06_20_035902_create_oauth_access_tokens_table.php b/database/migrations/2025_06_20_035902_create_oauth_access_tokens_table.php new file mode 100644 index 0000000..3e50f7f --- /dev/null +++ b/database/migrations/2025_06_20_035902_create_oauth_access_tokens_table.php @@ -0,0 +1,41 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->foreignUuid('client_id'); + $table->string('name')->nullable(); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->timestamps(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_access_tokens'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/database/migrations/2025_06_20_035903_create_oauth_refresh_tokens_table.php b/database/migrations/2025_06_20_035903_create_oauth_refresh_tokens_table.php new file mode 100644 index 0000000..afb3c55 --- /dev/null +++ b/database/migrations/2025_06_20_035903_create_oauth_refresh_tokens_table.php @@ -0,0 +1,37 @@ +char('id', 80)->primary(); + $table->char('access_token_id', 80)->index(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_refresh_tokens'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/database/migrations/2025_06_20_035904_create_oauth_clients_table.php b/database/migrations/2025_06_20_035904_create_oauth_clients_table.php new file mode 100644 index 0000000..9794dc8 --- /dev/null +++ b/database/migrations/2025_06_20_035904_create_oauth_clients_table.php @@ -0,0 +1,42 @@ +uuid('id')->primary(); + $table->nullableMorphs('owner'); + $table->string('name'); + $table->string('secret')->nullable(); + $table->string('provider')->nullable(); + $table->text('redirect_uris'); + $table->text('grant_types'); + $table->boolean('revoked'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_clients'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/database/migrations/2025_06_20_035905_create_oauth_device_codes_table.php b/database/migrations/2025_06_20_035905_create_oauth_device_codes_table.php new file mode 100644 index 0000000..ea07831 --- /dev/null +++ b/database/migrations/2025_06_20_035905_create_oauth_device_codes_table.php @@ -0,0 +1,42 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->foreignUuid('client_id')->index(); + $table->char('user_code', 8)->unique(); + $table->text('scopes'); + $table->boolean('revoked'); + $table->dateTime('user_approved_at')->nullable(); + $table->dateTime('last_polled_at')->nullable(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_device_codes'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +};