@@ -2,6 +2,7 @@ import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
2
2
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres" ;
3
3
import { RedisClient } from "@elizaos/adapter-redis" ;
4
4
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite" ;
5
+ import { SupabaseDatabaseAdapter } from "@elizaos/adapter-supabase" ;
5
6
import { AutoClientInterface } from "@elizaos/client-auto" ;
6
7
import { DiscordClientInterface } from "@elizaos/client-discord" ;
7
8
import { FarcasterAgentClient } from "@elizaos/client-farcaster" ;
@@ -456,7 +457,24 @@ export function getTokenForProvider(
456
457
}
457
458
458
459
function initializeDatabase ( dataDir : string ) {
459
- if ( process . env . POSTGRES_URL ) {
460
+ if ( process . env . SUPABASE_URL && process . env . SUPABASE_ANON_KEY ) {
461
+ elizaLogger . info ( "Initializing Supabase connection..." ) ;
462
+ const db = new SupabaseDatabaseAdapter (
463
+ process . env . SUPABASE_URL ,
464
+ process . env . SUPABASE_ANON_KEY
465
+ ) ;
466
+
467
+ // Test the connection
468
+ db . init ( )
469
+ . then ( ( ) => {
470
+ elizaLogger . success ( "Successfully connected to Supabase database" ) ;
471
+ } )
472
+ . catch ( ( error ) => {
473
+ elizaLogger . error ( "Failed to connect to Supabase:" , error ) ;
474
+ } ) ;
475
+
476
+ return db ;
477
+ } else if ( process . env . POSTGRES_URL ) {
460
478
elizaLogger . info ( "Initializing PostgreSQL connection..." ) ;
461
479
const db = new PostgresDatabaseAdapter ( {
462
480
connectionString : process . env . POSTGRES_URL ,
@@ -466,9 +484,7 @@ function initializeDatabase(dataDir: string) {
466
484
// Test the connection
467
485
db . init ( )
468
486
. then ( ( ) => {
469
- elizaLogger . success (
470
- "Successfully connected to PostgreSQL database"
471
- ) ;
487
+ elizaLogger . success ( "Successfully connected to PostgreSQL database" ) ;
472
488
} )
473
489
. catch ( ( error ) => {
474
490
elizaLogger . error ( "Failed to connect to PostgreSQL:" , error ) ;
@@ -483,10 +499,19 @@ function initializeDatabase(dataDir: string) {
483
499
} ) ;
484
500
return db ;
485
501
} else {
486
- const filePath =
487
- process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
488
- // ":memory:";
502
+ const filePath = process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
503
+ elizaLogger . info ( `Initializing SQLite database at ${ filePath } ...` ) ;
489
504
const db = new SqliteDatabaseAdapter ( new Database ( filePath ) ) ;
505
+
506
+ // Test the connection
507
+ db . init ( )
508
+ . then ( ( ) => {
509
+ elizaLogger . success ( "Successfully connected to SQLite database" ) ;
510
+ } )
511
+ . catch ( ( error ) => {
512
+ elizaLogger . error ( "Failed to connect to SQLite:" , error ) ;
513
+ } ) ;
514
+
490
515
return db ;
491
516
}
492
517
}
0 commit comments