001package io.ebeaninternal.dbmigration.ddlgeneration.platform;
002
003import io.ebean.config.DatabaseConfig;
004import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
005import io.ebeaninternal.dbmigration.migration.AddHistoryTable;
006import io.ebeaninternal.dbmigration.migration.DropHistoryTable;
007import io.ebeaninternal.dbmigration.model.MTable;
008
009/**
010 * Defines the implementation for adding history support to a table.
011 */
012public interface PlatformHistoryDdl {
013
014  /**
015   * Configure typically reading the necessary parameters from DatabaseConfig and Platform.
016   */
017  void configure(DatabaseConfig config, PlatformDdl platformDdl);
018
019  /**
020   * Creates a new table and add history support to the table using platform specific mechanism.
021   */
022  void createWithHistory(DdlWrite writer, MTable table);
023
024  /**
025   * Drop history support for the given table.
026   */
027  void dropHistoryTable(DdlWrite writer, DropHistoryTable dropHistoryTable);
028
029  /**
030   * Add history support to the given table.
031   */
032  void addHistoryTable(DdlWrite writer, AddHistoryTable addHistoryTable);
033
034  /**
035   * Regenerate the history triggers/stored function due to column added/dropped/included or excluded.
036   * 
037   * Note: This function may be called multiple times for the same table.
038   */
039  default void updateTriggers(DdlWrite writer, String tableName) {
040    // nop
041  }
042
043  /**
044   * When history is table based, then alters on the live tables are applied also to the history tables. This is required for
045   * DbTriggerBased histories or on platforms like Hana, which are not SQL2011 history compatible (at least from DDL perspective)
046   */
047  interface TableBased extends PlatformHistoryDdl {
048    /**
049     * Returns the history table name with propert quotes.
050     */
051    public String historyTableName(String baseTableName);
052  }
053}