mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:50:18 +00:00
57c3ecb175
* Add initial Rules Engine model Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * WIP - Add API layer Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Add async consumer Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Use Named queries and single topics Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Update rules listing Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Enable consumers with no transformer Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Move RE to addons Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Fix HTTP server host Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Remove unused code Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> * Remove cache for the time being Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> --------- Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package postgres
|
|
|
|
import (
|
|
_ "github.com/jackc/pgx/v5/stdlib" // required for SQL access
|
|
migrate "github.com/rubenv/sql-migrate"
|
|
)
|
|
|
|
func Migration() *migrate.MemoryMigrationSource {
|
|
return &migrate.MemoryMigrationSource{
|
|
Migrations: []*migrate.Migration{
|
|
{
|
|
Id: "rules_01",
|
|
// VARCHAR(36) for colums with IDs as UUIDS have a maximum of 36 characters
|
|
// STATUS 0 to imply enabled and 1 to imply disabled
|
|
Up: []string{
|
|
`CREATE TABLE IF NOT EXISTS rules (
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
name VARCHAR(1024),
|
|
domain_id VARCHAR(36) NOT NULL,
|
|
metadata JSONB,
|
|
created_at TIMESTAMP,
|
|
updated_at TIMESTAMP,
|
|
updated_by VARCHAR(254),
|
|
input_channel VARCHAR(36),
|
|
input_topic TEXT,
|
|
output_channel VARCHAR(36),
|
|
output_topic TEXT,
|
|
status SMALLINT NOT NULL DEFAULT 0 CHECK (status >= 0),
|
|
logic_type SMALLINT NOT NULL DEFAULT 0 CHECK (status >= 0),
|
|
logic_value BYTEA,
|
|
recurring_time TIMESTAMP[],
|
|
recurring_type SMALLINT,
|
|
recurring_period SMALLINT
|
|
)`,
|
|
},
|
|
Down: []string{
|
|
`DROP TABLE IF EXISTS rules`,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|