Files
speckle-server/packages/server/modules/comments/migrations/20220222173000_comments.js
T
Kristaps Fabians Geikins bde148f286 chore(server): migrating fully to ESM (#5042)
* wip

* some extra fixes

* stuff kinda works?

* need to figure out mocks

* need to figure out mocks

* fix db listener

* gqlgen fix

* minor gqlgen watch adjustment

* lint fixes

* delete old codegen file

* converting migrations to ESM

* getModuleDIrectory

* vitest sort of works

* added back ts-vitest

* resolve gql double load

* fixing test timeout configs

* TSC lint fix

* fix automate tests

* moar debugging

* debugging

* more debugging

* codegen update

* server works

* yargs migrated

* chore(server): getting rid of global mocks for Server ESM (#5046)

* got rid of email mock

* got rid of comment mocks

* got rid of multi region mocks

* got rid of stripe mock

* admin override mock updated

* removed final mock

* fixing import.meta.resolve calls

* another import.meta.resolve fix

* added requested test

* nyc ESM fix

* removed unneeded deps + linting

* yarn lock forgot to commit

* tryna fix flakyness

* email capture util fix

* sendEmail fix

* fix TSX check

* sender transporter fix + CR comments

* merge main fix

* test fixx

* circleci fix

* gqlgen bigint fix

* error formatter fix

* more error formatting improvements

* esmloader added to Dockerfile

* more dockerfile fixes

* bg jobs fix
2025-07-14 10:26:19 +03:00

63 lines
2.0 KiB
JavaScript

// /* istanbul ignore file */
const up = async (knex) => {
await knex.schema.createTable('comments', (table) => {
table.string('id', 10).primary()
table
.string('streamId', 10)
.references('id')
.inTable('streams')
.notNullable()
.index()
.onDelete('cascade')
table.string('authorId', 10).references('id').inTable('users').notNullable().index()
// table.timestamp( 'createdAt' ).defaultTo( knex.fn.now( ) )
table.specificType('createdAt', 'TIMESTAMPTZ(3)').defaultTo(knex.fn.now())
table.specificType('updatedAt', 'TIMESTAMPTZ(3)').defaultTo(knex.fn.now())
table.text('text')
table.text('screenshot')
table.jsonb('data')
table.boolean('archived').defaultTo(false).notNullable()
table
.string('parentComment', 10)
.references('id')
.inTable('comments')
.defaultTo(null)
})
// Comments >- -< Stream or Commit or Object or Comment
await knex.schema.createTable('comment_links', (table) => {
table
.string('commentId', 10)
.references('id')
.inTable('comments')
.onDelete('cascade')
//foreign keys are not enforced cause of the multiple table that can be referenced
table.string('resourceId').notNullable()
table
.string('resourceType')
.notNullable()
.checkIn(['stream', 'commit', 'object', 'comment'])
})
// Tracks when user has last seen a specific comment thread.
await knex.schema.createTable('comment_views', (table) => {
table
.string('commentId', 10)
.references('id')
.inTable('comments')
.onDelete('cascade')
table.string('userId', 10).references('id').inTable('users')
table.specificType('viewedAt', 'TIMESTAMPTZ(3)').defaultTo(knex.fn.now())
table.primary(['commentId', 'userId'])
})
}
const down = async (knex) => {
await knex.schema.dropTableIfExists('comment_views')
await knex.schema.dropTableIfExists('comment_links')
await knex.schema.dropTableIfExists('comments')
}
export { up, down }