diff --git a/ghost/core/core/server/data/migrations/versions/5.59/2023-08-07-11-17-05-add-posts-published-at-index.js b/ghost/core/core/server/data/migrations/versions/5.59/2023-08-07-11-17-05-add-posts-published-at-index.js index abf78fcaba..5784ac5d9b 100644 --- a/ghost/core/core/server/data/migrations/versions/5.59/2023-08-07-11-17-05-add-posts-published-at-index.js +++ b/ghost/core/core/server/data/migrations/versions/5.59/2023-08-07-11-17-05-add-posts-published-at-index.js @@ -1,4 +1,5 @@ const logging = require('@tryghost/logging'); +const DatabaseInfo = require('@tryghost/database-info'); const {createNonTransactionalMigration} = require('../../utils'); const INDEX_NAME = 'posts_published_at_index'; @@ -7,7 +8,7 @@ module.exports = createNonTransactionalMigration( async function up(knex) { let hasIndex = false; - if (knex.client.config.client === 'sqlite3') { + if (DatabaseInfo.isSQLite(knex)) { const result = await knex.raw(`select * from sqlite_master where type = 'index' and tbl_name = 'posts' and name = '${INDEX_NAME}'`); hasIndex = (result.length !== 0); } else { @@ -29,7 +30,7 @@ module.exports = createNonTransactionalMigration( async function down(knex) { let missingIndex = false; - if (knex.client.config.client === 'sqlite3') { + if (DatabaseInfo.isSQLite(knex)) { const result = await knex.raw(`select * from sqlite_master where type = 'index' and tbl_name = 'posts' and name = '${INDEX_NAME}'`); missingIndex = (result.length === 0); } else { diff --git a/ghost/core/test/regression/api/content/posts.test.js b/ghost/core/test/regression/api/content/posts.test.js index 7f86ae434f..c7296c46f6 100644 --- a/ghost/core/test/regression/api/content/posts.test.js +++ b/ghost/core/test/regression/api/content/posts.test.js @@ -302,24 +302,28 @@ describe('api/endpoints/content/posts', function () { before (function () { publicPost = testUtils.DataGenerator.forKnex.createPost({ slug: 'free-to-see', - visibility: 'public' + visibility: 'public', + published_at: new Date('2023-07-15T04:20:30.000+00:00') }); membersPost = testUtils.DataGenerator.forKnex.createPost({ slug: 'thou-shalt-not-be-seen', - visibility: 'members' + visibility: 'members', + published_at: new Date('2023-07-20T04:20:30.000+00:00') }); paidPost = testUtils.DataGenerator.forKnex.createPost({ slug: 'thou-shalt-be-paid-for', - visibility: 'paid' + visibility: 'paid', + published_at: new Date('2023-07-25T04:20:30.000+00:00') }); membersPostWithPaywallCard = testUtils.DataGenerator.forKnex.createPost({ slug: 'thou-shalt-have-a-taste', visibility: 'members', mobiledoc: '{"version":"0.3.1","markups":[],"atoms":[],"cards":[["paywall",{}]],"sections":[[1,"p",[[0,[],0,"Free content"]]],[10,0],[1,"p",[[0,[],0,"Members content"]]]]}', - html: '

Free content

Members content

' + html: '

Free content

Members content

', + published_at: new Date('2023-07-30T04:20:30.000+00:00') }); return testUtils.fixtures.insertPosts([