import { Database } from '@nozbe/watermelondb';
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite';
import schema from './schema';
import Chat from './models/Chat';
import Message from './models/Message';
import { BlockedUser } from './models';
import { migrations } from './migrations';

const adapter = new SQLiteAdapter({
  schema,
  dbName: 'WatermelonDB',
  onSetUpError: (error) => {
    console.error('Database setup error:', error);
  },
  migrations
});

export const database = new Database({
  adapter,
  modelClasses: [Chat, Message, BlockedUser]
});
