Method: Messaging::Adapters::Postgres::Categories#create

Defined in:
lib/messaging/adapters/postgres/categories.rb

#create(name) ⇒ Category

Creates a table partition for the given category

Parameters:

  • name (String)

    the name of the category

Returns:



24
25
26
27
28
29
30
31
32
# File 'lib/messaging/adapters/postgres/categories.rb', line 24

def create(name)
  table_name = Category.table_name_for(name)
  sql = "    CREATE TABLE IF NOT EXISTS messaging.\#{table_name}\n    PARTITION OF messaging.messages FOR VALUES IN ('\#{name}');\n  SQL\n  connection.execute sql\n  Category.new(name, table_name)\nend\n"