legion-data 1.11.7 → 1.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +12 -2
- data/.github/workflows/database-migrations.yml +84 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -0
- data/README.md +54 -12
- data/lib/legion/data/encryption/key_provider.rb +1 -1
- data/lib/legion/data/migrations/140_add_apollo_entries_embedding.rb +19 -0
- data/lib/legion/data/migrations/141_add_apollo_entries_archive_embedding.rb +19 -0
- data/lib/legion/data/migrations/142_add_apollo_entries_embedding_space_id.rb +9 -0
- data/lib/legion/data/migrations/143_add_apollo_entries_archive_embedding_space_id.rb +9 -0
- data/lib/legion/data/migrations/144_add_apollo_entries_embedding_dimensions.rb +9 -0
- data/lib/legion/data/migrations/145_add_apollo_entries_archive_embedding_dimensions.rb +9 -0
- data/lib/legion/data/migrations/146_add_apollo_entries_embedding_provenance.rb +16 -0
- data/lib/legion/data/migrations/147_add_apollo_entries_archive_embedding_provenance.rb +16 -0
- data/lib/legion/data/migrations/148_add_apollo_entries_embedding_lookup_index.rb +9 -0
- data/lib/legion/data/migrations/149_add_apollo_entries_content_hash_owner_index.rb +12 -0
- data/lib/legion/data/migrations/150_drop_apollo_entries_global_content_hash_index.rb +16 -0
- data/lib/legion/data/version.rb +1 -1
- metadata +13 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8ef8efbf88b799ee069d12c48760ff94637b6f54bd7e861ef83339ab8bbb7d7
|
|
4
|
+
data.tar.gz: 2a7af3ed19e03277544f1329917d9ba0feb43de7d8b4361cf8ed77950b1332be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e4864b80cba6d65abf5fb63dbaf4753e97e793b6a3eca8e52d55cc3e36f8b57374f84c143db563784ee7157f067f9cd079ae8ad1384443abaedd05c1ed58997
|
|
7
|
+
data.tar.gz: 783c1d28d8c17c075330ed2b0e6dc61aea3b5b1191a9899df7ec55a6e26c5896f182391ff903dd387ba42a5eb843fe3940e2dbbb536dc35f821d78683314c4fb
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
services:
|
|
24
24
|
postgres:
|
|
25
|
-
image:
|
|
25
|
+
image: pgvector/pgvector:0.8.7-pg16
|
|
26
26
|
env:
|
|
27
27
|
POSTGRES_USER: legion
|
|
28
28
|
POSTGRES_PASSWORD: legion
|
|
@@ -42,13 +42,23 @@ jobs:
|
|
|
42
42
|
bundler-cache: true
|
|
43
43
|
- name: Run RSpec (PostgreSQL adapter)
|
|
44
44
|
env:
|
|
45
|
+
HOME: ${{ runner.temp }}/legion-data-postgres-home
|
|
46
|
+
LEGION_DNS_BOOTSTRAP: "false"
|
|
45
47
|
LEGION_DATA_ADAPTER: postgres
|
|
46
48
|
LEGION_DATA_HOST: 127.0.0.1
|
|
47
49
|
LEGION_DATA_PORT: 5432
|
|
48
50
|
LEGION_DATA_USER: legion
|
|
49
51
|
LEGION_DATA_PASSWORD: legion
|
|
50
52
|
LEGION_DATA_DATABASE: legionio
|
|
51
|
-
run:
|
|
53
|
+
run: |
|
|
54
|
+
mkdir -p "$HOME" tmp
|
|
55
|
+
bundle exec rspec --format json --out tmp/rspec_results.json --format progress --out tmp/rspec_progress.txt > tmp/rspec_console.log 2>&1
|
|
56
|
+
- name: Upload PostgreSQL spec results
|
|
57
|
+
if: always()
|
|
58
|
+
uses: actions/upload-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: rspec-postgres
|
|
61
|
+
path: tmp/rspec_*
|
|
52
62
|
|
|
53
63
|
lint:
|
|
54
64
|
permissions:
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
name: Database Migrations
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
databases:
|
|
14
|
+
name: "Migrations (${{ matrix.adapter }}, Ruby ${{ matrix.ruby }})"
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
timeout-minutes: 15
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
adapter: [sqlite, postgres]
|
|
21
|
+
ruby: ['3.4', '4.0']
|
|
22
|
+
services:
|
|
23
|
+
postgres:
|
|
24
|
+
image: ${{ matrix.adapter == 'postgres' && 'pgvector/pgvector:0.8.7-pg17' || '' }}
|
|
25
|
+
env:
|
|
26
|
+
POSTGRES_USER: legion
|
|
27
|
+
POSTGRES_PASSWORD: legion
|
|
28
|
+
POSTGRES_DB: legionio
|
|
29
|
+
ports:
|
|
30
|
+
- 5432:5432
|
|
31
|
+
options: >-
|
|
32
|
+
--health-cmd pg_isready
|
|
33
|
+
--health-interval 10s
|
|
34
|
+
--health-timeout 5s
|
|
35
|
+
--health-retries 5
|
|
36
|
+
env:
|
|
37
|
+
LEGION_DNS_BOOTSTRAP: "false"
|
|
38
|
+
LEGION_DATA_ADAPTER: ${{ matrix.adapter }}
|
|
39
|
+
LEGION_DATA_HOST: 127.0.0.1
|
|
40
|
+
LEGION_DATA_PORT: 5432
|
|
41
|
+
LEGION_DATA_USER: legion
|
|
42
|
+
LEGION_DATA_PASSWORD: legion
|
|
43
|
+
LEGION_DATA_DATABASE: legionio
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v4
|
|
46
|
+
- uses: ruby/setup-ruby@v1
|
|
47
|
+
with:
|
|
48
|
+
ruby-version: ${{ matrix.ruby == '4.0' && '4.0.5' || matrix.ruby }}
|
|
49
|
+
bundler-cache: true
|
|
50
|
+
- name: Verify actual database backend, schema, and extension
|
|
51
|
+
env:
|
|
52
|
+
HOME: ${{ runner.temp }}/legion-data-migration-home
|
|
53
|
+
run: |
|
|
54
|
+
mkdir -p "$HOME"
|
|
55
|
+
bundle exec ruby -rrspec -e '
|
|
56
|
+
require_relative "spec/spec_helper"
|
|
57
|
+
db = Legion::Data.connection
|
|
58
|
+
expected_adapter = ENV.fetch("LEGION_DATA_ADAPTER").to_sym
|
|
59
|
+
abort "connected to #{db.database_type}, expected #{expected_adapter}" unless db.database_type == expected_adapter
|
|
60
|
+
migration_path = File.expand_path("lib/legion/data/migrations")
|
|
61
|
+
latest_migration = Dir.glob(File.join(migration_path, "*.rb")).filter_map { |file| File.basename(file)[/\A(\d+)/, 1]&.to_i }.max
|
|
62
|
+
version_table = %i[schema_info schema_migrations sequel_migrations].find { |table| db.table_exists?(table) }
|
|
63
|
+
applied_version = db[version_table].max(:version).to_i
|
|
64
|
+
abort "schema #{applied_version}, expected #{latest_migration}" unless applied_version == latest_migration
|
|
65
|
+
puts "Database adapter: #{db.database_type}; schema version: #{applied_version}"
|
|
66
|
+
if db.database_type == :postgres
|
|
67
|
+
version = db[:pg_extension].where(extname: "vector").get(:extversion)
|
|
68
|
+
abort "pgvector is not installed" unless version
|
|
69
|
+
puts "pgvector version: #{version}"
|
|
70
|
+
end
|
|
71
|
+
Legion::Data.shutdown
|
|
72
|
+
'
|
|
73
|
+
- name: Run full RSpec suite
|
|
74
|
+
env:
|
|
75
|
+
HOME: ${{ runner.temp }}/legion-data-migration-home
|
|
76
|
+
run: |
|
|
77
|
+
mkdir -p "$HOME" tmp
|
|
78
|
+
bundle exec rspec --format json --out tmp/rspec_results.json --format progress --out tmp/rspec_progress.txt > tmp/rspec_console.log 2>&1
|
|
79
|
+
- name: Upload database spec results
|
|
80
|
+
if: always()
|
|
81
|
+
uses: actions/upload-artifact@v4
|
|
82
|
+
with:
|
|
83
|
+
name: migrations-${{ matrix.adapter }}-ruby-${{ matrix.ruby }}
|
|
84
|
+
path: tmp/rspec_*
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Legion::Data Changelog
|
|
2
2
|
|
|
3
|
+
## [1.11.9] - 2026-11-11
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Fix the non-tenant encryption crash in #87 by using the supported `Legion::Crypt.cs` key API instead of `default_encryption_key`. Crypt initialization failures still propagate rather than falling back to a development key; tenant-scoped key retrieval is unchanged.
|
|
7
|
+
- Verify default-scoped encrypted-column persistence across fresh processes with real `legion-crypt`, including invalid-key rejection. Crypt remains a test-only dependency, not a required runtime dependency of Data.
|
|
8
|
+
|
|
9
|
+
## [1.11.8] - 2026-11-10
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Add SQLite JSON-text embedding storage and nullable embedding-space, dimension, and provenance metadata for active and archived Apollo entries. PostgreSQL retains `vector(1024)` and every existing ANN index; legacy metadata remains unknown until reembedding.
|
|
13
|
+
- Add ownership-scoped active content-hash uniqueness without rewriting hashes or deleting records. Create the replacement index before removing global uniqueness; rollback restores the old constraint when the data permits it.
|
|
14
|
+
- Add a separate SQLite/PostgreSQL 17/pgvector migration workflow on Ruby 3.4 and 4.0 while retaining the existing CI workflow and jobs.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Honor the requested test database adapter, prohibit PostgreSQL fallback to SQLite, and provide pgvector in the existing PostgreSQL 16 job. Exercise real migration chains, rollback boundaries, and PostgreSQL-specific fixtures.
|
|
18
|
+
|
|
3
19
|
## [1.11.7] - 2026-11-06
|
|
4
20
|
|
|
5
21
|
### Changed
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Core responsibilities:
|
|
|
18
18
|
| Audit and governance | `audit_log`, `audit_records`, `governance_events`, archive manifests |
|
|
19
19
|
| Identity and RBAC | providers, principals, identities, groups, memberships, role grants, runner grants |
|
|
20
20
|
| LLM ledger | conversations, model-visible messages, inference requests/responses, routing, metrics, tool calls, policy/security events |
|
|
21
|
-
| Apollo knowledge | PostgreSQL `pgvector`
|
|
21
|
+
| Apollo knowledge | PostgreSQL `pgvector` and SQLite JSON-text embeddings, relations, expertise, access logs |
|
|
22
22
|
| Local state | on-node SQLite cognitive state, independent of the shared database |
|
|
23
23
|
|
|
24
24
|
The schema is portable by default across SQLite, MySQL, and PostgreSQL. PostgreSQL-only behavior is isolated to features that need PostgreSQL, such as Apollo vector columns.
|
|
@@ -398,7 +398,7 @@ SQLite lock waits use a Ruby busy handler that releases the GVL between retries,
|
|
|
398
398
|
|
|
399
399
|
`data.statement_timeout` (default 5,000 ms) and `data.lock_timeout` (default 2,000 ms) are applied before every PostgreSQL connection enters the pool, including startup and replacement connections. Set a value to `null` to leave that server setting unchanged, or `0` to explicitly disable the corresponding PostgreSQL timeout.
|
|
400
400
|
|
|
401
|
-
PostgreSQL
|
|
401
|
+
PostgreSQL Apollo vector storage requires the `pgvector` extension:
|
|
402
402
|
|
|
403
403
|
```sql
|
|
404
404
|
CREATE EXTENSION IF NOT EXISTS vector;
|
|
@@ -526,7 +526,16 @@ Restore preserves original IDs and restores parent/master links after inserting
|
|
|
526
526
|
|
|
527
527
|
Each archive batch receives a UUID before upload. S3, Azure, and local object paths use `legion-archive/<table>/<year>/<month>/batch_<uuid>.jsonl.gz`; the same UUID is stored in `archive_manifest.batch_id`. Repeated runs do not reuse numbered object names. Existing manifest paths remain valid; no stored objects are renamed. Direct `Archiver.upload_batch` callers must supply `batch_id:` instead of `batch_n:`.
|
|
528
528
|
|
|
529
|
-
### Encryption
|
|
529
|
+
### Encryption Keys and Cache
|
|
530
|
+
|
|
531
|
+
When Crypt and `Crypt::PartitionKeys` are loaded, the default scope (`tenant_id: nil`) uses
|
|
532
|
+
the supported `Legion::Crypt.cs` cluster-key API. Keep the cluster secret persistent across
|
|
533
|
+
restarts to retain access to encrypted records. Crypt initialization failures propagate;
|
|
534
|
+
they do not select the development fallback key. Encrypted columns require binary storage.
|
|
535
|
+
The no-Crypt development fallback is unchanged.
|
|
536
|
+
|
|
537
|
+
This default-scope fix does not repair tenant-scoped Crypt integration or implement the
|
|
538
|
+
separate per-tenant Vault master-key provisioning and erasure lifecycle.
|
|
530
539
|
|
|
531
540
|
The default scope (`tenant_id: nil`) and tenant IDs have separate cache entries, including a tenant literally named `__default__`. Restart processes or clear existing key-provider caches when upgrading. This fix does not rewrite existing ciphertext: if that tenant name was used with the old cache, assess records encrypted with the wrong scope's key and re-encrypt them with the intended key. The reader does not fall back to another scope's key.
|
|
532
541
|
|
|
@@ -595,10 +604,33 @@ All new tables follow a column convention. Required fields are present on every
|
|
|
595
604
|
| `ApolloExpertise` | `apollo_expertise` | Per-agent domain expertise — PostgreSQL only |
|
|
596
605
|
| `ApolloAccessLog` | `apollo_access_log` | Apollo access audit log — PostgreSQL only |
|
|
597
606
|
|
|
598
|
-
Apollo
|
|
607
|
+
The legacy flat Apollo model classes require PostgreSQL with `pgvector`. The namespaced `Legion::Data::Model::Apollo::*` models use the available Apollo tables on PostgreSQL and SQLite.
|
|
599
608
|
|
|
600
609
|
The `Legion::Data::Model::Identity::*`, `Apollo::*`, and `RBAC::*` namespaces provide cleaner Sequel model names for API-facing code while preserving the legacy flat model classes. Official LLM lifecycle models live under `Legion::Data::Models::LLM`.
|
|
601
610
|
|
|
611
|
+
### Apollo Embedding Storage
|
|
612
|
+
|
|
613
|
+
Migrations 140–150 add the storage fields needed by the Apollo consumer without changing the
|
|
614
|
+
established PostgreSQL `vector(1024)` columns or removing any ANN indexes. SQLite gains
|
|
615
|
+
JSON-text embedding columns. Active and archived entries gain nullable `embedding_space_id`,
|
|
616
|
+
`embedding_dimensions`, and `embedding_provenance`; provenance uses PostgreSQL JSONB or
|
|
617
|
+
SQLite text. Model identity and dimensions are separate facts: two 1024-dimensional vectors
|
|
618
|
+
are not necessarily from a compatible embedding space.
|
|
619
|
+
|
|
620
|
+
Existing rows, hashes, and PostgreSQL vectors are preserved. Legacy metadata remains null;
|
|
621
|
+
reembedding must supply genuine model provenance rather than inferring it from vector length.
|
|
622
|
+
These migrations do not change embedding routing or add support for arbitrary vector sizes.
|
|
623
|
+
|
|
624
|
+
Active content-hash uniqueness is scoped by `access_scope` and owner. Global entries share
|
|
625
|
+
one boundary regardless of owner; restricted owners and legacy null owners remain distinct.
|
|
626
|
+
Archived copies remain permitted. The new unique index is created before the old one is
|
|
627
|
+
removed, so a failed upgrade does not leave deduplication unprotected.
|
|
628
|
+
|
|
629
|
+
Each migration changes one table. Rollback restores the original global unique index when
|
|
630
|
+
the records satisfy it; conflicting ownership-scoped duplicates cause a database constraint
|
|
631
|
+
failure without deleting records. Reversing the additions removes their metadata and SQLite
|
|
632
|
+
embedding columns. PostgreSQL vectors and existing ANN indexes are unchanged in both directions.
|
|
633
|
+
|
|
602
634
|
### Identity Namespace Models
|
|
603
635
|
|
|
604
636
|
| Model | Table | Description |
|
|
@@ -668,6 +700,10 @@ Numbered Sequel DSL migrations run automatically on startup (`auto_migrate: true
|
|
|
668
700
|
| 077–090 | Portable LLM lifecycle schema: conversations, messages, inference requests/responses, route attempts, inference metrics, provider-requested tool calls, compactions, policy/security, and registry events |
|
|
669
701
|
| 091–096 | Portable identity companion schema with integer primary keys, public UUIDs, provider capabilities, principals, identities, groups, memberships, and audit log |
|
|
670
702
|
| 097 | LLM dispatch identifiers for fleet operation, correlation, idempotency, provider instance, and dispatch path |
|
|
703
|
+
| 140–141 | JSON-text embedding columns for non-PostgreSQL active and archived Apollo entries |
|
|
704
|
+
| 142–147 | Nullable embedding-space identity, dimensions, and provenance, one column per migration |
|
|
705
|
+
| 148 | Active embedding-profile lookup index |
|
|
706
|
+
| 149–150 | Ownership-scoped hash uniqueness, installed before removing the old global unique index |
|
|
671
707
|
|
|
672
708
|
Run migrations standalone:
|
|
673
709
|
|
|
@@ -727,15 +763,21 @@ bundle exec rspec --format json --out tmp/rspec_results.json --format progress -
|
|
|
727
763
|
bundle exec rubocop -A # zero offenses expected
|
|
728
764
|
```
|
|
729
765
|
|
|
730
|
-
|
|
731
|
-
To exercise the same lifecycle suite on PostgreSQL, set `LEGION_DATA_ADAPTER=postgres` and
|
|
766
|
+
The full suite defaults to SQLite. Set `LEGION_DATA_ADAPTER=postgres` plus
|
|
732
767
|
`LEGION_DATA_HOST`, `LEGION_DATA_PORT`, `LEGION_DATA_USER`, `LEGION_DATA_PASSWORD`, and
|
|
733
|
-
`LEGION_DATA_DATABASE`
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
fixtures.
|
|
768
|
+
`LEGION_DATA_DATABASE` to exercise shared models and migrations against a **disposable
|
|
769
|
+
PostgreSQL database**. PostgreSQL 16+ needs `vector` and `uuid-ossp` available, and the test
|
|
770
|
+
role needs extension-installation and `CREATEDB` privileges. Apollo examples create and
|
|
771
|
+
drop uniquely named databases and apply the real chain through 139 before exercising
|
|
772
|
+
140–150. PostgreSQL setup prohibits SQLite fallback and verifies the actual adapter.
|
|
773
|
+
Intentionally SQLite-specific unit fixtures and local cognitive storage remain SQLite.
|
|
774
|
+
|
|
775
|
+
Always use a fresh temporary `HOME`, `LEGION_DNS_BOOTSTRAP=false`, and the real `RBENV_ROOT`
|
|
776
|
+
when using rbenv. SQLite test setup deletes its database under HOME.
|
|
777
|
+
|
|
778
|
+
The existing `ci.yml` workflow retains its jobs, including PostgreSQL 16 with pgvector.
|
|
779
|
+
The additional `database-migrations.yml` covers SQLite and PostgreSQL 17/pgvector on
|
|
780
|
+
Ruby 3.4 and 4.0, verifies the backend/schema, runs the full suite, and uploads results.
|
|
739
781
|
|
|
740
782
|
This repo also includes a pre-commit configuration:
|
|
741
783
|
|
|
@@ -30,7 +30,7 @@ module Legion
|
|
|
30
30
|
log.debug "Deriving Vault key for tenant #{tenant_id}"
|
|
31
31
|
Legion::Crypt::PartitionKeys.derive(tenant_id: tenant_id)
|
|
32
32
|
elsif crypt_available?
|
|
33
|
-
Legion::Crypt.
|
|
33
|
+
Legion::Crypt.cs
|
|
34
34
|
else
|
|
35
35
|
log.warn 'Legion::Crypt unavailable, falling back to dev encryption key'
|
|
36
36
|
local_key
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
unless adapter_scheme == :postgres
|
|
6
|
+
alter_table(:apollo_entries) do
|
|
7
|
+
add_column :embedding, String, text: true, null: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
down do
|
|
13
|
+
unless adapter_scheme == :postgres
|
|
14
|
+
alter_table(:apollo_entries) do
|
|
15
|
+
drop_column :embedding
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
unless adapter_scheme == :postgres
|
|
6
|
+
alter_table(:apollo_entries_archive) do
|
|
7
|
+
add_column :embedding, String, text: true, null: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
down do
|
|
13
|
+
unless adapter_scheme == :postgres
|
|
14
|
+
alter_table(:apollo_entries_archive) do
|
|
15
|
+
drop_column :embedding
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
provenance_type = adapter_scheme == :postgres ? :jsonb : :text
|
|
6
|
+
alter_table(:apollo_entries) do
|
|
7
|
+
add_column :embedding_provenance, provenance_type, null: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
down do
|
|
12
|
+
alter_table(:apollo_entries) do
|
|
13
|
+
drop_column :embedding_provenance
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
provenance_type = adapter_scheme == :postgres ? :jsonb : :text
|
|
6
|
+
alter_table(:apollo_entries_archive) do
|
|
7
|
+
add_column :embedding_provenance, provenance_type, null: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
down do
|
|
12
|
+
alter_table(:apollo_entries_archive) do
|
|
13
|
+
drop_column :embedding_provenance
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
change do
|
|
5
|
+
owner = Sequel.case({ { access_scope: 'global' } => 0 }, Sequel.function(:coalesce, :identity_principal_id, 0))
|
|
6
|
+
alter_table(:apollo_entries) do
|
|
7
|
+
add_index [:content_hash, :access_scope, owner],
|
|
8
|
+
unique: true, name: :idx_apollo_content_hash_owner,
|
|
9
|
+
where: Sequel.~(status: 'archived') & Sequel.~(content_hash: nil)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
alter_table(:apollo_entries) do
|
|
6
|
+
drop_index :content_hash, name: :idx_apollo_content_hash
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
down do
|
|
11
|
+
alter_table(:apollo_entries) do
|
|
12
|
+
add_index :content_hash, unique: true, name: :idx_apollo_content_hash,
|
|
13
|
+
where: Sequel.~(status: 'archived')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/legion/data/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion-data
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.11.
|
|
4
|
+
version: 1.11.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -106,6 +106,7 @@ files:
|
|
|
106
106
|
- ".github/CODEOWNERS"
|
|
107
107
|
- ".github/dependabot.yml"
|
|
108
108
|
- ".github/workflows/ci.yml"
|
|
109
|
+
- ".github/workflows/database-migrations.yml"
|
|
109
110
|
- ".gitignore"
|
|
110
111
|
- ".pre-commit-config.yaml"
|
|
111
112
|
- ".rubocop.yml"
|
|
@@ -288,6 +289,17 @@ files:
|
|
|
288
289
|
- lib/legion/data/migrations/137_preserve_task_archive_fields.rb
|
|
289
290
|
- lib/legion/data/migrations/138_add_append_claims.rb
|
|
290
291
|
- lib/legion/data/migrations/139_create_task_logs.rb
|
|
292
|
+
- lib/legion/data/migrations/140_add_apollo_entries_embedding.rb
|
|
293
|
+
- lib/legion/data/migrations/141_add_apollo_entries_archive_embedding.rb
|
|
294
|
+
- lib/legion/data/migrations/142_add_apollo_entries_embedding_space_id.rb
|
|
295
|
+
- lib/legion/data/migrations/143_add_apollo_entries_archive_embedding_space_id.rb
|
|
296
|
+
- lib/legion/data/migrations/144_add_apollo_entries_embedding_dimensions.rb
|
|
297
|
+
- lib/legion/data/migrations/145_add_apollo_entries_archive_embedding_dimensions.rb
|
|
298
|
+
- lib/legion/data/migrations/146_add_apollo_entries_embedding_provenance.rb
|
|
299
|
+
- lib/legion/data/migrations/147_add_apollo_entries_archive_embedding_provenance.rb
|
|
300
|
+
- lib/legion/data/migrations/148_add_apollo_entries_embedding_lookup_index.rb
|
|
301
|
+
- lib/legion/data/migrations/149_add_apollo_entries_content_hash_owner_index.rb
|
|
302
|
+
- lib/legion/data/migrations/150_drop_apollo_entries_global_content_hash_index.rb
|
|
291
303
|
- lib/legion/data/model.rb
|
|
292
304
|
- lib/legion/data/models/apollo/access_log.rb
|
|
293
305
|
- lib/legion/data/models/apollo/entries.rb
|