Skip to content

Commit

Permalink
small fixes to migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Nov 14, 2024
1 parent 9504a05 commit 7922355
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 0 additions & 2 deletions migrations/postgres/002_entities_content_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CREATE INDEX idx_autnum_content_number ON entities USING gin ((content->>'number
CREATE INDEX idx_autsys_content_number ON entities USING gin ((content->>'number') gin_trgm_ops) WHERE etype = 'AutonomousSystem';
CREATE INDEX idx_domainrec_content_domain ON entities USING gin ((content->>'domain') gin_trgm_ops) WHERE etype = 'DomainRecord';
CREATE INDEX idx_email_content_address ON entities USING gin ((content->>'address') gin_trgm_ops) WHERE etype = 'EmailAddress';
CREATE INDEX idx_finger_content_value ON entities USING gin ((content->>'value') gin_trgm_ops) WHERE etype = 'Fingerprint';
CREATE INDEX idx_fqdn_content_name ON entities USING gin ((content->>'name') gin_trgm_ops) WHERE etype = 'FQDN';
CREATE INDEX idx_ipaddr_content_address ON entities USING gin ((content->>'address') gin_trgm_ops) WHERE etype = 'IPAddress';
CREATE INDEX idx_ipnetrec_content_cidr ON entities USING gin ((content->>'cidr') gin_trgm_ops) WHERE etype = 'IPNetRecord';
Expand All @@ -28,7 +27,6 @@ DROP INDEX IF EXISTS idx_ipnetrec_content_handle;
DROP INDEX IF EXISTS idx_ipnetrec_content_cidr;
DROP INDEX IF EXISTS idx_ipaddr_content_address;
DROP INDEX IF EXISTS idx_fqdn_content_name;
DROP INDEX IF EXISTS idx_finger_content_value;
DROP INDEX IF EXISTS idx_email_content_address;
DROP INDEX IF EXISTS idx_domainrec_content_domain;
DROP INDEX IF EXISTS idx_autsys_content_number;
Expand Down
4 changes: 4 additions & 0 deletions migrations/postgres/embed.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

package postgres

import (
Expand Down
10 changes: 6 additions & 4 deletions migrations/postgres/example_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package postgres_test
// Copyright © by Jeff Foley 2017-2024. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0

package postgres

import (
"fmt"
"log"
"os"

"github.com/owasp-amass/asset-db/migrations/postgres"
migrate "github.com/rubenv/sql-migrate"
pg "gorm.io/driver/postgres"
"gorm.io/gorm"
)

func ExampleMigrations() {

user := "postgres"
if u, ok := os.LookupEnv("POSTGRES_USER"); ok {
user = u
Expand All @@ -39,7 +41,7 @@ func ExampleMigrations() {
sqlDb, _ := db.DB()

migrationsSource := migrate.EmbedFileSystemMigrationSource{
FileSystem: postgres.Migrations(),
FileSystem: Migrations(),
Root: "/",
}

Expand Down
4 changes: 1 addition & 3 deletions migrations/sqlite3/002_entities_content_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ CREATE INDEX idx_autnum_content_number ON entities (content->>'number' COLLATE N
CREATE INDEX idx_autsys_content_number ON entities (content->>'number' COLLATE NOCASE) WHERE etype = 'AutonomousSystem';
CREATE INDEX idx_domainrec_content_domain ON entities (content->>'domain' COLLATE NOCASE) WHERE etype = 'DomainRecord';
CREATE INDEX idx_email_content_address ON entities (content->>'address' COLLATE NOCASE) WHERE etype = 'EmailAddress';
CREATE INDEX idx_finger_content_value ON entities (content->>'value' COLLATE NOCASE) WHERE etype = 'Fingerprint';
CREATE INDEX idx_fqdn_content_name ON entities (content->>'name' COLLATE NOCASE) WHERE etype = 'FQDN';
CREATE INDEX idx_ipaddr_content_address ON entities (content->>'address' COLLATE NOCASE) WHERE etype = 'IPAddress';
CREATE INDEX idx_ipnetrec_content_cidr ON entities (content->>'cidr' COLLATE NOCASE) WHERE etype = 'IPNetRecord';
Expand All @@ -14,7 +13,7 @@ CREATE INDEX idx_netblock_content_cidr ON entities (content->>'cidr' COLLATE NOC
CREATE INDEX idx_org_content_name ON entities (content->>'name' COLLATE NOCASE) WHERE etype = 'Organization';
CREATE INDEX idx_person_content_full_name ON entities (content->>'full_name' COLLATE NOCASE) WHERE etype = 'Person';
CREATE INDEX idx_tls_content_serial_number ON entities (content->>'serial_number' COLLATE NOCASE) WHERE etype = 'TLSCertificate';
CREATE INDEX idx_url_content_url ON entities (content->>'url') WHERE etype = 'URL';
CREATE INDEX idx_url_content_url ON entities (content->>'url' COLLATE NOCASE) WHERE etype = 'URL';

-- +migrate Down

Expand All @@ -27,7 +26,6 @@ DROP INDEX IF EXISTS idx_ipnetrec_content_handle;
DROP INDEX IF EXISTS idx_ipnetrec_content_cidr;
DROP INDEX IF EXISTS idx_ipaddr_content_address;
DROP INDEX IF EXISTS idx_fqdn_content_name;
DROP INDEX IF EXISTS idx_finger_content_value;
DROP INDEX IF EXISTS idx_email_content_address;
DROP INDEX IF EXISTS idx_domainrec_content_domain;
DROP INDEX IF EXISTS idx_autsys_content_number;
Expand Down
1 change: 0 additions & 1 deletion migrations/sqlite3/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func ExampleMigrations() {

dsn := "test.db"
if v, ok := os.LookupEnv("SQLITE3_DB"); ok {
dsn = v
Expand Down

0 comments on commit 7922355

Please sign in to comment.