Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add migration indexes #573

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('authtoken_filter_by_timestamp'))
vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
*/
const index = {
name: 'authtoken_migration_timestamp',
source: Collection('AuthToken'),
values: [
{ field: ['data', 'updated'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('backup_migration_timestamp'))
*/
const index = {
name: 'backup_migration_timestamp',
source: Collection('Backup'),
values: [
{ field: ['data', 'created'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('content_migration_timestamp'))
*/
const index = {
name: 'content_migration_timestamp',
source: Collection('Content'),
values: [
{ field: ['data', 'created'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
31 changes: 31 additions & 0 deletions packages/db/fauna/resources/Migration_indexes/migration_pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('pin_migration_timestamp'))
*/
const index = {
name: 'pin_migration_timestamp',
source: Collection('Pin'),
values: [
{ field: ['data', 'updated'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('pinrequest_migration_timestamp'))
*/
const index = {
name: 'pinrequest_migration_timestamp',
source: Collection('PinRequest'),
values: [
{ field: ['data', 'updated'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('pinSync_migration_timestamp'))
vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
*/
const index = {
name: 'pinSyncRequest_migration_timestamp',
source: Collection('PinSyncRequest'),
values: [
{ field: ['data', 'created'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('upload_migration_timestamp'))
*/
const index = {
name: 'upload_migration_timestamp',
source: Collection('Upload'),
values: [
{ field: ['data', 'updated'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
31 changes: 31 additions & 0 deletions packages/db/fauna/resources/Migration_indexes/migration_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fauna from 'faunadb'

const {
CreateIndex,
Collection,
If,
Index,
Exists,
Not
} = fauna

/**
* Usage:
*
* Match(Index('user_migration_timestamp'))
*/
const index = {
name: 'user_migration_timestamp',
source: Collection('User'),
values: [
{ field: ['data', 'created'] },
{ field: 'ref' }
]
}

// indexes cannot be updated
export default If(
Not(Exists(Index(index.name))),
CreateIndex(index),
Index(index.name)
)
1 change: 1 addition & 0 deletions packages/db/tools/import-fql-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const main = async () => {
}
await uploadResources('function')
await uploadResources('index')
await uploadResources('migration_indexes')
}

/**
Expand Down