Genie Discord forum

Author AvatarCameron Pfiffer
8/5/2023, 2:30:34 AM

Looking at this example:

module CreateTableMovies

import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table

function up()
  create_table(:movies) do
    [
      primary_key()
      column(:type, :string, limit = 10)
      column(:title, :string, limit = 100)
      column(:directors, :string, limit = 100)
      column(:actors, :string, limit = 250)
      column(:country, :string, limit = 100)
      column(:year, :integer, limit = 4)
      column(:rating, :string, limit = 10)
      column(:categories, :string, limit = 100)
      column(:description, :string, limit = 1_000)
    ]
  end

  add_index(:movies, :title)
  add_index(:movies, :actors)
  add_index(:movies, :categories)
  add_index(:movies, :description)
end

function down()
  drop_table(:movies)
end

end

What are the valid types for column? I see :integer and :string here but I can't find any documentations on the others.

Author Avatarabhimanyuaryan
8/5/2023, 1:10:55 PM

hey @Cameron Pfiffer if you are using SQLite then mapping are

Dict{Symbol, Symbol}(
  :char       => :TEXT,
  :string     => :TEXT,
  :text       => :TEXT,
  :integer    => :INTEGER,
  :int        => :INTEGER,
  :float      => :FLOAT,
  :decimal    => :DECIMAL,
  :datetime   => :DATETIME,
  :timestamp  => :INTEGER,
  :time       => :TIME,
  :date       => :DATE,
  :binary     => :BLOB,
  :boolean    => :BOOLEAN,
  :bool       => :BOOLEAN
)
Author Avatarabhimanyuaryan
8/5/2023, 1:12:43 PM

Yes documentation is lacking for SearchLight. I have long wanted to fix it maybe soon