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

const now = Date.now();

export const reversionDb: Template = {
    slug: 'reversion-database',
    name: 'Reversion',
    shortDescription: 'Version control for model instances',
    description:
        'Django extension that provides version control for model instances, allowing you to roll back to any point in a model history and recover deleted instances.',
    image,
    imageDark,
    tags: ['Postgres', 'Python', 'Django'],
    featured: true,
    url: 'https://github.com/etianen/django-reversion',
    diagram: {
        id: 'reversion_db',
        name: 'reversion-database',
        createdAt: new Date(),
        updatedAt: new Date(),
        databaseType: DatabaseType.POSTGRESQL,
        tables: [
            {
                id: '5vbs1o9jcijqaos2r7ufyf3qk',
                name: 'django_content_type',
                schema: 'public',
                x: 813.8339153520599,
                y: -167.89819045086784,
                fields: [
                    {
                        id: 'fz4jkfpns4wgyfdyhw51smsk0',
                        name: 'id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                ],
                indexes: [
                    {
                        id: 'pl9jzcxgahlfkkigj9ftgp99m',
                        name: 'django_content_type_pkey',
                        unique: true,
                        fieldIds: ['fz4jkfpns4wgyfdyhw51smsk0'],
                        createdAt: now,
                    },
                ],
                color: '#7175fa',
                isView: false,
                isMaterializedView: false,
                createdAt: now,
            },
            {
                id: '97rot1dndzf83yt3armaynm66',
                name: 'reversion_version',
                schema: 'public',
                x: 453.0003174647601,
                y: -161.63156611283586,
                fields: [
                    {
                        id: 'oekrmcccwzb4m7yr14sve140y',
                        name: 'id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '5rcck5wqsezl9mr8y6vwbj9nu',
                        name: 'object_id',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'v3ek62rrsh8gdtr7jpnuremi3',
                        name: 'format',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'qs80fnu5l0my70mqr8wrxhxpi',
                        name: 'serialized_data',
                        type: {
                            id: 'text',
                            name: 'text',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '1tl6ctq3orl37as2egw6as7l2',
                        name: 'object_repr',
                        type: {
                            id: 'text',
                            name: 'text',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '754680oc0l4vnc1cltlg2u6j5',
                        name: 'content_type_id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: '4zgrxtfln1vbn11g1fksoi71n',
                        name: 'revision_id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'poog75wj64fgrb3q1llpb5iua',
                        name: 'db',
                        type: {
                            id: 'character_varying',
                            name: 'character varying',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                ],
                indexes: [
                    {
                        id: 'dl89wmn0ubu9wtxgcz3lfgwr5',
                        name: 'reversion_version_db_content_type_id_object_id_revision_id_uniq',
                        unique: true,
                        fieldIds: [
                            'poog75wj64fgrb3q1llpb5iua',
                            '754680oc0l4vnc1cltlg2u6j5',
                            '5rcck5wqsezl9mr8y6vwbj9nu',
                            '4zgrxtfln1vbn11g1fksoi71n',
                        ],
                        createdAt: now,
                    },
                    {
                        id: 'zt2sezsi9e79znlazfd321ld3',
                        name: 'reversion_version_pkey',
                        unique: true,
                        fieldIds: ['oekrmcccwzb4m7yr14sve140y'],
                        createdAt: now,
                    },
                ],
                color: '#ff6363',
                isView: false,
                isMaterializedView: false,
                createdAt: now,
            },
            {
                id: 'hlsk0icz2mso3czxx45g7dcbj',
                name: 'auth_user',
                schema: 'public',
                x: -216.9672275210761,
                y: 92.16671957746007,
                fields: [
                    {
                        id: 'yrh05ijpg4e0g0catmqipbs0b',
                        name: 'id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                ],
                indexes: [
                    {
                        id: '0oklodaz95u913bl53xfw2cgw',
                        name: 'auth_user_pkey',
                        unique: true,
                        fieldIds: ['yrh05ijpg4e0g0catmqipbs0b'],
                        createdAt: now,
                    },
                ],
                color: '#ff6363',
                isView: false,
                isMaterializedView: false,
                createdAt: now,
            },
            {
                id: 'm2bz2erjdddq1gkllitzz85lf',
                name: 'reversion_revision',
                schema: 'public',
                x: 100,
                y: -191.39803171848786,
                fields: [
                    {
                        id: 'n4ck81ah0i122hwo1temykxov',
                        name: 'id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: true,
                        unique: true,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'ktyja9ud79wjeyow1e6oqtf9y',
                        name: 'date_created',
                        type: {
                            id: 'timestamp_without_time_zone',
                            name: 'timestamp without time zone',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'slkveui0isgbxsm0ovktp7p4o',
                        name: 'comment',
                        type: {
                            id: 'text',
                            name: 'text',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: false,
                        createdAt: now,
                    },
                    {
                        id: 'l27mx98db22pvpl9wx6a6aptx',
                        name: 'user_id',
                        type: {
                            id: 'integer',
                            name: 'integer',
                        },
                        primaryKey: false,
                        unique: false,
                        nullable: true,
                        createdAt: now,
                    },
                ],
                indexes: [
                    {
                        id: 'u3rbquia5fbikru96pheubqph',
                        name: 'reversion_revision_date_created_index',
                        unique: false,
                        fieldIds: ['ktyja9ud79wjeyow1e6oqtf9y'],
                        createdAt: now,
                    },
                    {
                        id: 'w7eva3mrl7taqschfapaf85sh',
                        name: 'reversion_revision_pkey',
                        unique: true,
                        fieldIds: ['n4ck81ah0i122hwo1temykxov'],
                        createdAt: now,
                    },
                ],
                color: '#ffe374',
                isView: false,
                isMaterializedView: false,
                createdAt: now,
            },
        ],
        relationships: [
            {
                id: '54riti2nvt8xb6bcpg4ctyz8f',
                name: 'reversion_version_revision_id_foreign',
                sourceSchema: 'public',
                targetSchema: 'public',
                sourceTableId: '97rot1dndzf83yt3armaynm66',
                targetTableId: 'm2bz2erjdddq1gkllitzz85lf',
                sourceFieldId: '4zgrxtfln1vbn11g1fksoi71n',
                targetFieldId: 'n4ck81ah0i122hwo1temykxov',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: now,
            },
            {
                id: 'bl05eigbvn8h4rsey6ugs949n',
                name: 'reversion_version_content_type_id_foreign',
                sourceSchema: 'public',
                targetSchema: 'public',
                sourceTableId: '97rot1dndzf83yt3armaynm66',
                targetTableId: '5vbs1o9jcijqaos2r7ufyf3qk',
                sourceFieldId: '754680oc0l4vnc1cltlg2u6j5',
                targetFieldId: 'fz4jkfpns4wgyfdyhw51smsk0',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: now,
            },
            {
                id: 'uneee946ch7dq8e6djh40sigv',
                name: 'reversion_revision_user_id_foreign',
                sourceSchema: 'public',
                targetSchema: 'public',
                sourceTableId: 'm2bz2erjdddq1gkllitzz85lf',
                targetTableId: 'hlsk0icz2mso3czxx45g7dcbj',
                sourceFieldId: 'l27mx98db22pvpl9wx6a6aptx',
                targetFieldId: 'yrh05ijpg4e0g0catmqipbs0b',
                sourceCardinality: 'many',
                targetCardinality: 'one',
                createdAt: now,
            },
        ],
        dependencies: [],
    },
};
