# Copyright 2021 The MLX Contributors
#
# SPDX-License-Identifier: Apache-2.0
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-initdb-config
  namespace: kubeflow
data:
  initdb.sql: |
    CREATE TABLE IF NOT EXISTS `pipelines` (
      `UUID` varchar(255) NOT NULL,
      `CreatedAtInSec` bigint(20) NOT NULL,
      `Name` varchar(255) NOT NULL,
      `Description` longtext NOT NULL,
      `Parameters` longtext NOT NULL,
      `Status` varchar(255) NOT NULL,
      `DefaultVersionId` varchar(255) DEFAULT NULL,
      `Namespace` varchar(63) DEFAULT '',
      PRIMARY KEY (`UUID`),
      UNIQUE KEY `name_namespace_index` (`Name`,`Namespace`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    CREATE TABLE IF NOT EXISTS `pipeline_versions` (
      `UUID` varchar(255) NOT NULL,
      `CreatedAtInSec` bigint(20) NOT NULL,
      `Name` varchar(255) NOT NULL,
      `Parameters` longtext NOT NULL,
      `PipelineId` varchar(255) NOT NULL,
      `Status` varchar(255) NOT NULL,
      `CodeSourceUrl` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`UUID`),
      UNIQUE KEY `idx_pipelineid_name` (`Name`,`PipelineId`),
      KEY `idx_pipeline_versions_CreatedAtInSec` (`CreatedAtInSec`),
      KEY `idx_pipeline_versions_PipelineId` (`PipelineId`),
      CONSTRAINT `pipeline_versions_PipelineId_pipelines_UUID_foreign` FOREIGN KEY (`PipelineId`) REFERENCES `pipelines` (`UUID`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
