import { Auth } from './Auth';
import { Attachment } from './Attachment';
import { Bucket } from './Bucket';
import { DBState } from './DBState';
import { Post, PostBucket } from './Post';
import { PostTag } from './PostTag';
import { Project } from './Project';
import { Tag } from './Tag';
import { User, addUserScopes } from './User';
import { UserPerms, addUserPermsScopes } from './UserPerms';
import { SqliteDialect } from '@sequelize/sqlite3';
import Sequelize from '@sequelize/core';


const sequelize = new Sequelize({
    dialect: SqliteDialect,
    storage: 'db.sqlite',
    models: [Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms],

});


const dbSync = (async ()=> await sequelize.sync())().then(()=>{
    addUserScopes();
    addUserPermsScopes();
});


export { sequelize, dbSync, Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms }