import { DatabaseType } from '@/lib/domain/database-type';
import type { Template } from '../templates-data';
import image from '@/assets/templates/devise-db.png';
import imageDark from '@/assets/templates/devise-db-dark.png';

const now = Date.now();

export const deviseDb: Template = {
    slug: 'devise-database',
    name: 'Devise',
    shortDescription: 'Flexible Auth for Rails applications',
    description:
        'Flexible authentication for Rails based on Warden, MVC with 10 modules, including DB Authenticatable, Registerable, and Recoverable.',
    image,
    imageDark,
    tags: ['Postgres', 'Open Source', 'Rails'],
    featured: true,
    url: 'https://github.com/heartcombo/devise',
    diagram: {
        id: 'devise_db',
        name: 'devise-database',
        createdAt: new Date(),
        updatedAt: new Date(),
        databaseType: DatabaseType.POSTGRESQL,
        tables: [
            {
                id: 'yha079pwna8c99bb8jawlaej3',
                name: 'users',
                schema: 'public',
                x: 40,
                y: 100,
                fields: [
                    {
                        id: 'tnnbdv2o6svxuz0wm7yp56rhn',
                        name: 'id',
                        type: {
                            id: 'bigint',
                            name: 'bigint',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'vkhvag7othohyjh6828ybk3ca',
                        name: 'email',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'wd49z62mufty2emt4ga95vtes',
                        name: 'encrypted_password',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '1vz318dy43ajqkltguj4cgu8b',
                        name: 'reset_password_token',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: '8ydqdfy4rhuiediufdhirc160',
                        name: 'reset_password_sent_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'eukr07x2egs3477q5bi11df0g',
                        name: 'remember_created_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'raxxzuz5nqbuf63628jmdx5ii',
                        name: 'sign_in_count',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'kb3ao9bj6gjab3y5cdwuc7b58',
                        name: 'current_sign_in_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'mm4knih0nyvhd4vvy6vr969dk',
                        name: 'last_sign_in_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'g1y49u7xrq1qu4gvm42f3q25y',
                        name: 'current_sign_in_ip',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'dutn6db8am2f58u96ou0f4ha3',
                        name: 'last_sign_in_ip',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'ipxhirbm3blfebww69xrq6rfc',
                        name: 'confirmation_token',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'q3robth7nuy6qoyncmkyfd2wr',
                        name: 'confirmed_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 's0ekzf665nsmkeljo30v36ymq',
                        name: 'confirmation_sent_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: '6lvgbsqnvdamibmbuhfxrvsp6',
                        name: 'unconfirmed_email',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'o29wwqt6ycsubf43yzypd40ua',
                        name: 'failed_attempts',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '2jbu40xg710e63y9p6l292vhl',
                        name: 'unlock_token',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: true,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'ribk8hlz1o926iinrs5ohob0s',
                        name: 'locked_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                    {
                        id: 'q6n7ulzw5qkwr23akuuyd2bzf',
                        name: 'created_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'a4azxp7ry1q743lgeot5pxz0m',
                        name: 'updated_at',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                ],
                indexes: [
                    {
                        id: '698pbewk499ajavfw1y50tgb4',
                        name: 'users_pkey',
                        unique: true,
                        fieldIds: ['tnnbdv2o6svxuz0wm7yp56rhn'],
                        createdAt: now,
                    },
                    {
                        id: '3oq1zywey14y8w67kyiork0zf',
                        name: 'users_email_unique',
                        unique: true,
                        fieldIds: ['vkhvag7othohyjh6828ybk3ca'],
                        createdAt: now,
                    },
                    {
                        id: 'jk7nrup4dw6xrx11boprthswy',
                        name: 'users_reset_password_token_unique',
                        unique: true,
                        fieldIds: ['1vz318dy43ajqkltguj4cgu8b'],
                        createdAt: now,
                    },
                    {
                        id: 'rh4czfl0w3nzd5xuqnx6bi9vx',
                        name: 'users_unlock_token_unique',
                        unique: true,
                        fieldIds: ['2jbu40xg710e63y9p6l292vhl'],
                        createdAt: now,
                    },
                    {
                        id: 'h5vv3jzsud0eeon3xs60xc651',
                        name: 'users_confirmation_token_unique',
                        unique: true,
                        fieldIds: ['ipxhirbm3blfebww69xrq6rfc'],
                        createdAt: now,
                    },
                ],
                color: '#4dee8a',
                isView: false,
                isMaterializedView: false,
                createdAt: now,
                width: 337,
            },
        ],
        relationships: [],
        dependencies: [],
    },
};
