github.com/quay/claircore@v1.5.28/datastore/postgres/migrations/migrations.go (about)

     1  package migrations
     2  
     3  import (
     4  	"database/sql"
     5  	"embed"
     6  
     7  	"github.com/remind101/migrate"
     8  )
     9  
    10  const (
    11  	IndexerMigrationTable = "libindex_migrations"
    12  	MatcherMigrationTable = "libvuln_migrations"
    13  )
    14  
    15  //go:embed */*.sql
    16  var fs embed.FS
    17  
    18  func runFile(n string) func(*sql.Tx) error {
    19  	b, err := fs.ReadFile(n)
    20  	return func(tx *sql.Tx) error {
    21  		if err != nil {
    22  			return err
    23  		}
    24  		if _, err := tx.Exec(string(b)); err != nil {
    25  			return err
    26  		}
    27  		return nil
    28  	}
    29  }
    30  
    31  var IndexerMigrations = []migrate.Migration{
    32  	{
    33  		ID: 1,
    34  		Up: runFile("indexer/01-init.sql"),
    35  	},
    36  	{
    37  		ID: 2,
    38  		Up: runFile("indexer/02-digests.sql"),
    39  	},
    40  	{
    41  		ID: 3,
    42  		Up: runFile("indexer/03-unique-manifest_index.sql"),
    43  	},
    44  	{
    45  		ID: 4,
    46  		Up: runFile("indexer/04-foreign-key-cascades.sql"),
    47  	},
    48  	{
    49  		ID: 5,
    50  		Up: runFile("indexer/05-delete-manifest-index-index.sql"),
    51  	},
    52  	{
    53  		ID: 6,
    54  		Up: runFile("indexer/06-file-artifacts.sql"),
    55  	},
    56  	{
    57  		ID: 7,
    58  		Up: runFile("indexer/07-index-manifest_index.sql"),
    59  	},
    60  }
    61  
    62  var MatcherMigrations = []migrate.Migration{
    63  	{
    64  		ID: 1,
    65  		Up: runFile("matcher/01-init.sql"),
    66  	},
    67  	{
    68  		ID: 2,
    69  		Up: runFile("matcher/02-indexes.sql"),
    70  	},
    71  	{
    72  		ID: 3,
    73  		Up: runFile("matcher/03-pyup-fingerprint.sql"),
    74  	},
    75  	{
    76  		ID: 4,
    77  		Up: runFile("matcher/04-enrichments.sql"),
    78  	},
    79  	{
    80  		ID: 5,
    81  		Up: runFile("matcher/05-uo_enrich-fkey.sql"),
    82  	},
    83  	{
    84  		ID: 6,
    85  		Up: runFile("matcher/06-delete-debian-update_operation.sql"),
    86  	},
    87  	{
    88  		ID: 7,
    89  		Up: runFile("matcher/07-force-alpine-update.sql"),
    90  	},
    91  	{
    92  		ID: 8,
    93  		Up: runFile("matcher/08-updater-status.sql"),
    94  	},
    95  	{
    96  		ID: 9,
    97  		Up: runFile("matcher/09-delete-pyupio.sql"),
    98  	},
    99  	{
   100  		ID: 10,
   101  		Up: runFile("matcher/10-delete-osv.sql"),
   102  	},
   103  	{
   104  		ID: 11,
   105  		Up: runFile("matcher/11-add-update_operation-mv.sql"),
   106  	},
   107  	{
   108  		ID: 12,
   109  		Up: runFile("matcher/12-add-latest_update_operation-index.sql"),
   110  	},
   111  }