/*
 * This file is generated by jOOQ.
 */
package com.databasir.dao.tables;


import com.databasir.dao.Databasir;
import com.databasir.dao.Keys;
import com.databasir.dao.tables.records.DataSourceRecord;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Identity;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Row9;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class DataSource extends TableImpl<DataSourceRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>databasir.data_source</code>
     */
    public static final DataSource DATA_SOURCE = new DataSource();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<DataSourceRecord> getRecordType() {
        return DataSourceRecord.class;
    }

    /**
     * The column <code>databasir.data_source.id</code>.
     */
    public final TableField<DataSourceRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");

    /**
     * The column <code>databasir.data_source.project_id</code>.
     */
    public final TableField<DataSourceRecord, Integer> PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.database_name</code>.
     */
    public final TableField<DataSourceRecord, String> DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.VARCHAR(512).nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.database_type</code>.
     */
    public final TableField<DataSourceRecord, String> DATABASE_TYPE = createField(DSL.name("database_type"), SQLDataType.VARCHAR(255).nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.url</code>.
     */
    public final TableField<DataSourceRecord, String> URL = createField(DSL.name("url"), SQLDataType.CLOB.nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.username</code>.
     */
    public final TableField<DataSourceRecord, String> USERNAME = createField(DSL.name("username"), SQLDataType.CLOB.nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.password</code>.
     */
    public final TableField<DataSourceRecord, String> PASSWORD = createField(DSL.name("password"), SQLDataType.CLOB.nullable(false), this, "");

    /**
     * The column <code>databasir.data_source.update_at</code>.
     */
    public final TableField<DataSourceRecord, LocalDateTime> UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");

    /**
     * The column <code>databasir.data_source.create_at</code>.
     */
    public final TableField<DataSourceRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");

    private DataSource(Name alias, Table<DataSourceRecord> aliased) {
        this(alias, aliased, null);
    }

    private DataSource(Name alias, Table<DataSourceRecord> aliased, Field<?>[] parameters) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
    }

    /**
     * Create an aliased <code>databasir.data_source</code> table reference
     */
    public DataSource(String alias) {
        this(DSL.name(alias), DATA_SOURCE);
    }

    /**
     * Create an aliased <code>databasir.data_source</code> table reference
     */
    public DataSource(Name alias) {
        this(alias, DATA_SOURCE);
    }

    /**
     * Create a <code>databasir.data_source</code> table reference
     */
    public DataSource() {
        this(DSL.name("data_source"), null);
    }

    public <O extends Record> DataSource(Table<O> child, ForeignKey<O, DataSourceRecord> key) {
        super(child, key, DATA_SOURCE);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Databasir.DATABASIR;
    }

    @Override
    public Identity<DataSourceRecord, Integer> getIdentity() {
        return (Identity<DataSourceRecord, Integer>) super.getIdentity();
    }

    @Override
    public UniqueKey<DataSourceRecord> getPrimaryKey() {
        return Keys.KEY_DATA_SOURCE_PRIMARY;
    }

    @Override
    public List<UniqueKey<DataSourceRecord>> getUniqueKeys() {
        return Arrays.asList(Keys.KEY_DATA_SOURCE_UK_PROJECT_ID);
    }

    @Override
    public DataSource as(String alias) {
        return new DataSource(DSL.name(alias), this);
    }

    @Override
    public DataSource as(Name alias) {
        return new DataSource(alias, this);
    }

    /**
     * Rename this table
     */
    @Override
    public DataSource rename(String name) {
        return new DataSource(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public DataSource rename(Name name) {
        return new DataSource(name, null);
    }

    // -------------------------------------------------------------------------
    // Row9 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row9<Integer, Integer, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
        return (Row9) super.fieldsRow();
    }
}
