@@ -2,17 +2,25 @@ const { Knex } = require('knex');
22
33/** @param {Knex } knex */
44exports . up = ( knex ) => {
5- return knex . schema . createTable ( 'personal_access_tokens' , ( table ) => {
6- table . increments ( 'id' ) . primary ( ) ;
7- table . string ( 'tokenable_type' ) ;
8- table . bigInteger ( 'tokenable_id' ) . index ( ) . unsigned ( ) ;
9- table . string ( 'name' ) ;
10- table . string ( 'abilities' ) . nullable ( ) ;
11- table . string ( 'payload' ) . nullable ( ) ;
12- table . integer ( 'ttl' ) . index ( ) . nullable ( ) ;
13- table . timestamp ( 'last_used_at' ) . nullable ( ) ;
14- table . timestamps ( true , true ) ;
15- } ) ;
5+ knex . schema . hasTable ( 'personal_access_tokens' )
6+ . then ( ( exists ) => {
7+ if ( ! exists ) {
8+ return knex . schema . createTable ( 'personal_access_tokens' , ( table ) => {
9+ table . increments ( 'id' ) . primary ( ) ;
10+ table . string ( 'tokenable_type' ) ;
11+ table . bigInteger ( 'tokenable_id' ) . index ( ) . unsigned ( ) ;
12+ table . string ( 'name' ) ;
13+ table . string ( 'abilities' ) . nullable ( ) ;
14+ table . string ( 'payload' ) . nullable ( ) ;
15+ table . integer ( 'ttl' ) . index ( ) . nullable ( ) ;
16+ table . timestamp ( 'last_used_at' ) . nullable ( ) ;
17+ table . timestamps ( true , true ) ;
18+ } ) ;
19+ }
20+ } )
21+ . catch ( ( error ) => {
22+ console . error ( 'Error checking for personal_access_tokens table:' , error ) ;
23+ } ) ;
1624}
1725
1826/** @param {Knex } knex */
0 commit comments