Class ParserSqlScript

java.lang.Object
migratedb.v1.core.internal.sqlscript.ParserSqlScript
All Implemented Interfaces:
Comparable<SqlScript>, SqlScript

public class ParserSqlScript extends Object implements SqlScript
  • Field Details

    • sqlStatements

      protected final List<SqlStatement> sqlStatements
      The sql statements contained in this script.
    • resource

      protected final Resource resource
      The resource containing the statements.
    • parser

      protected final Parser parser
  • Constructor Details

    • ParserSqlScript

      public ParserSqlScript(Parser parser, Resource resource, Resource metadataResource, boolean mixed)
      Creates a new sql script from this source.
      Parameters:
      resource - The sql script resource.
      metadataResource - The sql script metadata resource.
      mixed - Whether to allow mixing transactional and non-transactional statements within the same migration.
  • Method Details

    • parse

      protected void parse()
    • validate

      public void validate()
      Description copied from interface: SqlScript
      Validates this SQL script.
      Specified by:
      validate in interface SqlScript
    • getSqlStatements

      public SqlStatementIterator getSqlStatements()
      Specified by:
      getSqlStatements in interface SqlScript
      Returns:
      The sql statements contained in this script.
    • getSqlStatementCount

      public int getSqlStatementCount()
      Specified by:
      getSqlStatementCount in interface SqlScript
      Returns:
      The number of sql statements contained in this script.
    • getResource

      public final Resource getResource()
      Specified by:
      getResource in interface SqlScript
      Returns:
      The resource containing the statements.
    • executeInTransaction

      public boolean executeInTransaction()
      Description copied from interface: SqlScript
      Whether the execution should take place inside a transaction. This is useful for databases like PostgreSQL where certain statement can only execute outside a transaction.
      Specified by:
      executeInTransaction in interface SqlScript
      Returns:
      true if a transaction should be used (highly recommended), or false if not.
    • shouldExecute

      public boolean shouldExecute()
      Description copied from interface: SqlScript
      Whether the script should execute or not.
      Specified by:
      shouldExecute in interface SqlScript
      Returns:
      true if the script should execute, or false if not.
    • compareTo

      public int compareTo(SqlScript o)
      Specified by:
      compareTo in interface Comparable<SqlScript>
    • toString

      public String toString()
      Overrides:
      toString in class Object