Interface ISchemaBuilder

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DryRunSchemaBuilder, SchemaBuilder

public interface ISchemaBuilder extends AutoCloseable
  • Method Details

    • create

      @CheckReturnValue default ICreateTableBuilder create(String table)
      Create a new table. Will fail if a table with the same name already exists.

      Note: remember to call IBaseBuilder.execute()

      Note: to specify non-standard table names, use create(Token) with Token.literal(String)

      Parameters:
      table - that will be created, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      a builder that can be used to build the new table.
    • create

      @CheckReturnValue ICreateTableBuilder create(Token table)
      Create a new table. Will fail if a table with the same name already exists.

      Note: remember to call IBaseBuilder.execute()

      Parameters:
      table - that will be created.
      Returns:
      a builder that can be used to build the new table.
    • createIfNotExists

      @CheckReturnValue default ICreateTableBuilder createIfNotExists(String table)
      Create a new table. Does nothing a table with the same name already exists, no matter its contents.

      Note: remember to call IBaseBuilder.execute()

      Note: to specify non-standard table names, use createIfNotExists(Token) with Token.literal(String)

      Parameters:
      table - that will be created, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      a builder that can be used to build the new table.
    • createIfNotExists

      @CheckReturnValue ICreateTableBuilder createIfNotExists(Token table)
      Create a new table if it does not already exist. Does nothing if a table with the same name already exists, no matter its contents.

      Note: remember to call IBaseBuilder.execute()

      Parameters:
      table - that will be created if not already.
      Returns:
      a builder that can be used to build the new table.
    • alter

      @CheckReturnValue default IAlterTableBuilder alter(String table)
      Alter an existing table.

      Note: remember to call IBaseBuilder.execute()

      Note: to specify non-standard table names, use alter(Token) with Token.literal(String)

      Parameters:
      table - that will be altered, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      a builder that can be used to alter the table.
    • alter

      @CheckReturnValue IAlterTableBuilder alter(Token table)
      Alter an existing table.

      Note: remember to call IBaseBuilder.execute()

      Parameters:
      table - that will be altered.
      Returns:
      a builder that can be used to alter the table.
    • alterIfExists

      @CheckReturnValue default IAlterTableBuilder alterIfExists(String table)
      Alter an existing table if it exists.

      Note: remember to call IBaseBuilder.execute()

      Note: to specify non-standard table names, use alterIfExists(Token) with Token.literal(String)

      Parameters:
      table - that will be altered, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      a builder that can be used to alter the table.
    • alterIfExists

      @CheckReturnValue IAlterTableBuilder alterIfExists(Token table)
      Alter an existing table if it exists.

      Note: remember to call IBaseBuilder.execute()

      Parameters:
      table - that will be altered if it exists.
      Returns:
      a builder that can be used to alter the table.
    • drop

      default void drop(String table)
      Drop an existing table.

      Note: to specify non-standard table names, use drop(Token) with Token.literal(String)

      Parameters:
      table - that will be dropped, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
    • drop

      void drop(Token table)
      Drop an existing table.
      Parameters:
      table - that will be dropped.
    • dropIfExists

      default void dropIfExists(String table)
      Drop an existing table if it exists.

      Note: to specify non-standard table names, use dropIfExists(Token) with Token.literal(String)

      Parameters:
      table - that will be dropped, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
    • dropIfExists

      void dropIfExists(Token table)
      Drop an existing table if it exists.
      Parameters:
      table - that will be dropped.
    • exists

      @CheckReturnValue default boolean exists(String table)
      Check if a table exists.

      Note: to specify non-standard table names, use exists(Token) with Token.literal(String)

      Parameters:
      table - to be checked, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      true if the table exists, false otherwise
    • exists

      @CheckReturnValue boolean exists(Token table)
      Check if a table exists.
      Parameters:
      table - to be checked
      Returns:
      true if the table exists, false otherwise
    • columnExists

      @CheckReturnValue default boolean columnExists(String table, String column)
      Check if a column exists.

      Note: to specify non-standard table or column names, use columnExists(Token, Token)

      Parameters:
      table - the table to check in, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      column - the column to be checked, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      true if the column exists, false otherwise
    • columnExists

      @CheckReturnValue boolean columnExists(Token table, Token column)
      Check if a column exists.
      Parameters:
      table - the table to check in
      column - the column to be checked
      Returns:
      true if the column exists, false otherwise
    • createDatabaseAndUser

      void createDatabaseAndUser(String databaseName, String username, String password)
      Creates a new database and user. The user will be granted all privileges on the database.
      Parameters:
      databaseName - The name of the database to create
      username - The name of the user to create
      password - The password of the user to create
    • close

      void close()
      Specified by:
      close in interface AutoCloseable