Skip to content

Services db schema#291

Open
erangi-ar wants to merge 35 commits intobuerokratt:wipfrom
rootcodelabs:intents-db-schema
Open

Services db schema#291
erangi-ar wants to merge 35 commits intobuerokratt:wipfrom
rootcodelabs:intents-db-schema

Conversation

@erangi-ar
Copy link
Collaborator

No description provided.

Thirunayan22 and others added 30 commits December 16, 2025 12:33
Pulling changes from Burokratt WIP to rootcodelabs/RAG-Module wip
Get update from RAG-201-Fix into encrypt-llm-keys
update cron manager vault script
Sync rootcodelabs/RAG-Module wip with buerokratt/RAG-Module wip
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new database schema for a services table to support service management functionality in the RAG search system. The services table is designed to store service definitions with intent classification data for LLM-based routing.

Changes:

  • Added new Liquibase migration file rag-search-script-v5-services.sql that defines the services table and required ENUM types
  • Updated master.yml to include the new services migration before the prompt configuration migration

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
DSL/Liquibase/master.yml Added include directive for the new services migration file
DSL/Liquibase/changelog/rag-search-script-v5-services.sql New migration defining the services table with fields for service metadata, intent classification, configuration, and timestamps

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ruuter_type ruuter_request_type DEFAULT 'GET', -- ENUM: 'GET' or 'POST'
current_state service_state DEFAULT 'draft', -- ENUM: 'active', 'inactive', 'draft'
is_common BOOLEAN NOT NULL DEFAULT false,
deleted BOOLEAN NOT NULL DEFAULT false,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deleted field uses uppercase BOOLEAN (line 14) while other occurrences in the same file use lowercase (line 13). For consistency within this file, the casing should be uniform. The existing codebase also uses uppercase TRUE/FALSE (line 14) which is consistent.

Suggested change
deleted BOOLEAN NOT NULL DEFAULT false,
deleted boolean NOT NULL DEFAULT false,

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,32 @@
CREATE TABLE services (
-- Primary key
id BIGSERIAL PRIMARY KEY,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table is missing a primary key constraint name. Looking at other tables in the codebase (e.g., rag-search-script-v2-user-management.sql:19,31, rag-search-script-v3-configuration.sql:10), primary keys are explicitly named using "CONSTRAINT [tablename]_pkey PRIMARY KEY (id)". For consistency, this should be "CONSTRAINT services_pkey PRIMARY KEY" instead of just "PRIMARY KEY".

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +14
current_state service_state DEFAULT 'draft', -- ENUM: 'active', 'inactive', 'draft'
is_common BOOLEAN NOT NULL DEFAULT false,
deleted BOOLEAN NOT NULL DEFAULT false,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the schema design, queries are likely to filter by current_state (active/inactive/draft) and deleted (soft delete pattern). However, there are no indexes defined for these columns. If the table grows large, queries filtering by these fields (e.g., SELECT * FROM services WHERE deleted = false AND current_state = 'active') may have poor performance. Consider adding indexes on these columns, either individually or as a composite index.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +32
CREATE TABLE services (
-- Primary key
id BIGSERIAL PRIMARY KEY,

-- Basic service information
name TEXT NOT NULL,
description TEXT NOT NULL,
service_id TEXT NOT NULL UNIQUE,

-- Service classification
ruuter_type ruuter_request_type DEFAULT 'GET', -- ENUM: 'GET' or 'POST'
current_state service_state DEFAULT 'draft', -- ENUM: 'active', 'inactive', 'draft'
is_common BOOLEAN NOT NULL DEFAULT false,
deleted BOOLEAN NOT NULL DEFAULT false,

-- Intent classification data (for LLM)
slot TEXT NOT NULL DEFAULT '',
entities text[] NOT NULL DEFAULT '{}',
examples text[] NOT NULL DEFAULT '{}',

-- Service configuration
structure JSON NOT NULL DEFAULT '{}',
endpoints JSON NOT NULL DEFAULT '[]',

-- Timestamps
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Custom types used:
CREATE TYPE ruuter_request_type AS ENUM ('GET', 'POST');
CREATE TYPE service_state AS ENUM ('active', 'inactive', 'draft'); No newline at end of file
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom ENUM types (ruuter_request_type and service_state) are being created at lines 31-32, but they are referenced in the CREATE TABLE statement at lines 11-12. In SQL, types must be defined before they are used. This will cause the table creation to fail with an error about undefined types. The CREATE TYPE statements should be moved to appear before the CREATE TABLE statement.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,32 @@
CREATE TABLE services (
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new migration file is missing the Liquibase formatted SQL header and changeset declarations. Looking at other migration files in this codebase (e.g., rag-search-script-v2-user-management.sql, rag-search-script-v3-configuration.sql, rag-search-script-v5-prompt-config.sql), they all start with "-- liquibase formatted sql" followed by "-- changeset [author]:[changeset-id]" comments. This file should follow the same pattern for consistency and proper Liquibase tracking.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,32 @@
CREATE TABLE services (
-- Primary key
id BIGSERIAL PRIMARY KEY,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id field uses BIGSERIAL, but other tables in this codebase use "BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY" (see rag-search-script-v3-configuration.sql:5 and rag-search-script-v5-prompt-config.sql:5). While BIGSERIAL is functionally similar, using "BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY" would be more consistent with the established pattern in this codebase.

Copilot uses AI. Check for mistakes.
-- Basic service information
name TEXT NOT NULL,
description TEXT NOT NULL,
service_id TEXT NOT NULL UNIQUE,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service_id field is defined as UNIQUE but there's no explicit index name provided. While PostgreSQL will create an implicit index for UNIQUE constraints, for consistency with the naming conventions seen in this codebase and for explicit control, consider adding an explicitly named unique constraint or index. However, this is a minor point as the UNIQUE constraint will function correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +27
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp fields use TIMESTAMPTZ (line 26-27) while other tables in this codebase consistently use "TIMESTAMP WITH TIME ZONE" (see rag-search-script-v2-user-management.sql:18,30 and rag-search-script-v3-configuration.sql:8). While TIMESTAMPTZ is an alias for TIMESTAMP WITH TIME ZONE in PostgreSQL, using the full form would be more consistent with the established convention in this codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +27
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp defaults use NOW() (lines 26-27) while other tables in this codebase use CURRENT_TIMESTAMP (see rag-search-script-v2-user-management.sql:18,30 and rag-search-script-v3-configuration.sql:8). While both are functionally equivalent in PostgreSQL, using CURRENT_TIMESTAMP would be more consistent with the established pattern in this codebase.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,32 @@
CREATE TABLE services (
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table name "services" is not schema-qualified, unlike other tables in this codebase which use "public." prefix (see rag-search-script-v2-user-management.sql:7,22,26, rag-search-script-v3-configuration.sql:4, and rag-search-script-v5-prompt-config.sql:4). For consistency with the established convention, this should be "CREATE TABLE public.services".

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants