EctoTablestore.Migration.table

You're seeing just the function table, go back to EctoTablestore.Migration module for more information.

Returns a table struct that can be given to create/2.

Since Tablestore is a NoSQL service, there are up to 4 primary key(s) can be added when creation, the first added key is partition key when set partition_key option as false.

Examples

create table("products") do
  add :name, :string
  add :price, :integer
end

create table("products", partition_key: false) do
  add :name, :string
  add :price, :integer
end

Options

  • :partition_key - as true by default, and there will add an :id field as partition key with type as a large autoincrementing integer (as bigserial), Tablestore does not support bigserial type for primary keys, but can use the ex_aliyun_ots lib's wrapper - Sequence to implement it; when false, a partition key field is not generated on table creation.

  • :prefix - the prefix for the table.

  • :meta - define the meta information when create table, can see Tablestore's document for details:

  • :reserved_throughput_write - reserve the throughput for write when create table, an integer, the default value is 0;

  • :reserved_throughput_read - reserve the throughput for read when create table, an integer, the default value is 0;

  • :time_to_live - the survival time of the saved data, a.k.a TTL; an integer, unit as second, the default value is -1 (permanent preservation);

  • :deviation_cell_version_in_sec - maximum version deviation, the default value is 86400 seconds, which is 1 day;

  • stream_spec - set the stream specification of Tablestore:

    • is_enabled, open or close stream
    • expiration_time, the expiration time of the table's stream