scala.slick.migration.api

TableMigration

Related Docs: object TableMigration | package api

sealed abstract class TableMigration[T <: driver.JdbcDriver.Table[_]] extends SqlMigration with AstHelpers with Equals

The base class for table migrations. A table migration is a Migration that performs changes to a table.

See this class's methods for a list of available operations. Calling an operation method returns a new TableMigration that has that operation added, over operations contained in the original TableMigration. This allows for a nice method chaining syntax.

Like all Migrations, you can run the resulting TableMigration by calling its apply method (it expects an implicit Session). Being an SqlMigration you can also call the sql method to see the SQL statement(s) it uses.

This class is abstract; use its companion object as a factory to get an instance.

Self Type
TableMigration[T]
Example:
  1. object table1 extends Table[(Int, Int, Int)]("table1") {
      def col1 = column[Int]("col1")
      def col2 = column[Int]("col2")
      def col3 = column[Int]("col3")
      def * = col1 ~ col2 ~ col3
    }
    implicit val dialect = new H2Dialect
    val migration = TableMigration(table1)
                      .addColumns(_.col1, _.col2)
                      .addColumns(_.col3)
Linear Supertypes
Equals, AstHelpers, SqlMigration, Migration, AnyRef, Any
Known Subclasses
Ordering
  1. Grouped
  2. Alphabetic
  3. By inheritance
Inherited
  1. TableMigration
  2. Equals
  3. AstHelpers
  4. SqlMigration
  5. Migration
  6. AnyRef
  7. Any
Implicitly
  1. by MigrationConcat
  2. by any2stringadd
  3. by StringFormat
  4. by Ensuring
  5. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. abstract type Self <: TableMigration[T]

    The concrete type of this TableMigration (ReversibleTableMigration or IrreversibleTableMigration).* Operations that are in of themselves reversible will return an instance of this type.

Abstract Value Members

  1. abstract def data: TableMigrationData

    Attributes
    protected[scala.slick.migration.api]
  2. abstract def withData(data: TableMigrationData): Self

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. def &(n: ReversibleMigration): ReversibleMigrationSeq

    [use case] Append a ReversibleMigration to form either a ReversibleMigrationSeq if the left side of & is also a ReversibleMigration; or else a plain MigrationSeq

    [use case]

    Append a ReversibleMigration to form either a ReversibleMigrationSeq if the left side of & is also a ReversibleMigration; or else a plain MigrationSeq

    n

    the ReversibleMigration to append

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to MigrationConcat[TableMigration[T]] performed by method MigrationConcat in scala.slick.migration.api.Migration.
    Definition Classes
    MigrationConcat
    Full Signature

    def &[N <: Migration, O](n: N)(implicit ccm: CanConcatMigrations[TableMigration[T], N, O]): O

    Example:
    1. val combined = mig1 & mig2 & mig3
  4. def &(n: Migration): MigrationSeq

    [use case] Append another Migration to form a MigrationSeq

    [use case]

    Append another Migration to form a MigrationSeq

    n

    the Migration to append

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to MigrationConcat[TableMigration[T]] performed by method MigrationConcat in scala.slick.migration.api.Migration.
    Definition Classes
    MigrationConcat
    Full Signature

    def &[N <: Migration, O](n: N)(implicit ccm: CanConcatMigrations[TableMigration[T], N, O]): O

    Example:
    1. val combined = mig1 & mig2 & mig3
  5. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to any2stringadd[TableMigration[T]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  6. def ->[B](y: B): (TableMigration[T], B)

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to ArrowAssoc[TableMigration[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def addColumns(cols: (T) ⇒ Column[_]*): Self

    Add columns to the table.

    Add columns to the table. (If the table is being created, these may be incorporated into the CREATE TABLE statement.)

    cols

    zero or more column-returning functions, which are passed the table object.

    Example:
    1. tblMig.addColumns(_.col1, _.col2, _.column[Int]("fieldNotYetInTableDef"))
  9. def addForeignKeys(fkqs: (T) ⇒ ForeignKeyQuery[_ <: AbstractTable[_], _]*): Self

    Adds foreign key constraints.

    Adds foreign key constraints.

    fkqs

    zero or more ForeignKeyQuery-returning functions, which are passed the table object.

    Example:
    1. tblMig.addForeignKeys(_.fkDef)
  10. def addIndexes(indexes: (T) ⇒ Index*): Self

    Adds indexes

    Adds indexes

    indexes

    zero or more Index-returning functions, which are passed the table object.

    Example:
    1. tblMig.addIndexes(_.idxDef)
  11. def addPrimaryKeys(pks: (T) ⇒ PrimaryKey*): Self

    Adds primary key constraints.

    Adds primary key constraints.

    pks

    zero or more PrimaryKey-returning functions, which are passed the table object.

    Example:
    1. tblMig.addPrimaryKeys(_.pkDef)
  12. def alterColumnDefaults(cols: (T) ⇒ Column[_]*): IrreversibleTableMigration[T]

    Changes the default value of columns based on the column definitions in cols

    Changes the default value of columns based on the column definitions in cols

    cols

    zero or more column-returning functions, which are passed the table object.

    Example:
    1. tblMig.alterColumnDefaults(_.col1, _.column[Int]("col2", O.Default("notTheDefaultInTableDef")))
  13. def alterColumnNulls(cols: (T) ⇒ Column[_]*): IrreversibleTableMigration[T]

    Changes the nullability of columns based on the column definitions in cols

    Changes the nullability of columns based on the column definitions in cols

    cols

    zero or more column-returning functions, which are passed the table object.

    Example:
    1. tblMig.alterColumnNulls(_.col1, _.column[Int]("col2", O.NotNull))
  14. def alterColumnTypes(cols: (T) ⇒ Column[_]*): IrreversibleTableMigration[T]

    Changes the data type of columns based on the column definitions in cols

    Changes the data type of columns based on the column definitions in cols

    cols

    zero or more column-returning functions, which are passed the table object.

    Example:
    1. tblMig.alterColumnTypes(_.col1, _.column[NotTheTypeInTableDef]("col2"))
  15. def apply()(implicit session: SessionDef): Unit

    Runs all the SQL statements in a single transaction

    Runs all the SQL statements in a single transaction

    Definition Classes
    SqlMigrationMigration
  16. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  17. def canEqual(that: Any): Boolean

    Definition Classes
    TableMigration → Equals
  18. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def columnInfo(driver: JdbcDriver, column: FieldSymbol): ColumnInfo

    driver

    a Slick driver, used to extract ColumnInfo#sqlType and ColumnInfo#notNull by calling typeInfoFor

    returns

    a ColumnInfo representing the relevant information in column

    Attributes
    protected
    Definition Classes
    AstHelpers
  20. def create: Self

    Create the table.

    Create the table. Note: drop + create is allowed.

  21. def drop: IrreversibleTableMigration[T]

    Drop the table.

    Drop the table. Note: drop + create is allowed.

  22. def dropColumns(cols: (T) ⇒ Column[_]*): Self

    Drop columns.

    Drop columns.

    cols

    zero or more column-returning functions, which are passed the table object.

    Example:
    1. tblMig.dropColumns(_.col1, _.col2, _.column[Int]("oldFieldNotInTableDef"))
  23. def dropForeignKeys(fkqs: (T) ⇒ ForeignKeyQuery[_ <: AbstractTable[_], _]*): Self

    Drops foreign key constraints.

    Drops foreign key constraints.

    fkqs

    zero or more ForeignKeyQuery-returning functions, which are passed the table object.

    Example:
    1. tblMig.dropForeignKeys(_.fkDef)
  24. def dropIndexes(indexes: (T) ⇒ Index*): Self

    Drops indexes

    Drops indexes

    indexes

    zero or more Index-returning functions, which are passed the table object.

    Example:
    1. tblMig.dropIndexes(_.idxDef)
  25. def dropPrimaryKeys(pks: (T) ⇒ PrimaryKey*): Self

    Drops primary key constraints.

    Drops primary key constraints.

    pks

    zero or more PrimaryKey-returning functions, which are passed the table object.

    Example:
    1. tblMig.dropPrimaryKeys(_.pkDef)
  26. def ensuring(cond: (TableMigration[T]) ⇒ Boolean, msg: ⇒ Any): TableMigration[T]

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to Ensuring[TableMigration[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  27. def ensuring(cond: (TableMigration[T]) ⇒ Boolean): TableMigration[T]

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to Ensuring[TableMigration[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  28. def ensuring(cond: Boolean, msg: ⇒ Any): TableMigration[T]

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to Ensuring[TableMigration[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  29. def ensuring(cond: Boolean): TableMigration[T]

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to Ensuring[TableMigration[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  30. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  31. def equals(a: Any): Boolean

    Definition Classes
    TableMigration → Equals → AnyRef → Any
  32. def fieldSym(column: Column[_]): FieldSymbol

    returns

    a FieldSymbol representing the column

    Attributes
    protected
    Definition Classes
    AstHelpers
  33. def fieldSym(node: Node): Option[FieldSymbol]

    returns

    if node represents a reference to a table's column, that is, it is a Select(_, f: FieldSymbol), then Some(f); otherwise None

    Attributes
    protected
    Definition Classes
    AstHelpers
  34. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  35. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to StringFormat[TableMigration[T]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  36. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  37. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  38. def indexInfo(index: Index): IndexInfo

    returns

    an IndexInfo containing the relevant information from a Slick Index

    Attributes
    protected
    Definition Classes
    AstHelpers
  39. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  40. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  41. final def notify(): Unit

    Definition Classes
    AnyRef
  42. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  43. def rename(to: String): Self

    Rename the table

    Rename the table

    to

    the new name for the table

  44. def renameColumn(col: (T) ⇒ Column[_], to: String): Self

    Rename a column.

    Rename a column.

    col

    a column-returning function, which is passed the table object.

    Example:
    1. tblMig.renameColumns(_.col1, "newName")
  45. def renameIndex(index: (T) ⇒ Index, to: String): Self

    Renames an index

    Renames an index

    index

    an Index-returning function, which is passed the table object.

    Example:
    1. tblMig.renameIndex(_.idxDef, "newName")
  46. def sql: Seq[String]

    The SQL statements to run

    The SQL statements to run

    Definition Classes
    TableMigrationSqlMigration
  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  48. def tableInfo: TableInfo

  49. def tableInfo(table: TableNode): TableInfo

    table

    a Slick table object whose qualified name is needed

    returns

    a TableInfo representing the qualified name of table

    Attributes
    protected
    Definition Classes
    AstHelpers
  50. def toString(): String

    Definition Classes
    TableMigration → AnyRef → Any
  51. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. def [B](y: B): (TableMigration[T], B)

    Implicit information
    This member is added by an implicit conversion from TableMigration[T] to ArrowAssoc[TableMigration[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from Equals

Inherited from AstHelpers

Inherited from SqlMigration

Inherited from Migration

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion MigrationConcat from TableMigration[T] to MigrationConcat[TableMigration[T]]

Inherited by implicit conversion any2stringadd from TableMigration[T] to any2stringadd[TableMigration[T]]

Inherited by implicit conversion StringFormat from TableMigration[T] to StringFormat[TableMigration[T]]

Inherited by implicit conversion Ensuring from TableMigration[T] to Ensuring[TableMigration[T]]

Inherited by implicit conversion ArrowAssoc from TableMigration[T] to ArrowAssoc[TableMigration[T]]

Schema Manipulation Operations

Ungrouped