How to use knex.schema.hasTable method in qawolf

Best JavaScript code snippet using qawolf

20210331102611_initial_database_schema.js

Source:20210331102611_initial_database_schema.js Github

copy

Full Screen

1export const up = async (knex) => {2 if (!await knex.schema.hasTable('countries')) {3 await knex.schema.createTable('countries', table => {4 table.uuid('id').primary()5 table.string('code').unique()6 table.timestamp('createdAt').defaultTo(knex.fn.now())7 table.timestamp('updatedAt').nullable()8 })9 }10 if (!await knex.schema.hasTable('languages')) {11 await knex.schema.createTable('languages', table => {12 table.uuid('id').primary()13 table.string('code').unique()14 table.timestamp('createdAt').defaultTo(knex.fn.now())15 table.timestamp('updatedAt').nullable()16 })17 }18 if (!await knex.schema.hasTable('ratings')) {19 await knex.schema.createTable('ratings', table => {20 table.uuid('id').primary()21 table.string('code').unique()22 table.timestamp('createdAt').defaultTo(knex.fn.now())23 table.timestamp('updatedAt').nullable()24 })25 }26 if (!await knex.schema.hasTable('production_companies')) {27 await knex.schema.createTable('production_companies', table => {28 table.uuid('id').primary()29 table.string('name').unique()30 table.string('description', 10000)31 table.string('headquarters')32 table.string('logoPath')33 table.string('homepage')34 table.uuid('countryId').references('countries.id')35 table.string('tmdbId').unique()36 table.timestamp('createdAt').defaultTo(knex.fn.now())37 table.timestamp('updatedAt').nullable()38 })39 }40 if (!await knex.schema.hasTable('movie_genres')) {41 await knex.schema.createTable('movie_genres', table => {42 table.uuid('id').primary()43 table.string('name').unique()44 table.string('tmdbId').unique()45 table.timestamp('createdAt').defaultTo(knex.fn.now())46 table.timestamp('updatedAt').nullable()47 })48 }49 if (!await knex.schema.hasTable('tv_show_genres')) {50 await knex.schema.createTable('tv_show_genres', table => {51 table.uuid('id').primary()52 table.string('name').unique()53 table.string('tmdbId').unique()54 table.timestamp('createdAt').defaultTo(knex.fn.now())55 table.timestamp('updatedAt').nullable()56 })57 }58 if (!await knex.schema.hasTable('movies')) {59 await knex.schema.createTable('movies', table => {60 table.uuid('id').primary()61 table.uuid('ratingId').references('ratings.id')62 table.string('title').unique()63 table.string('tagline')64 table.string('description', 10000)65 table.decimal('voteAverage', 10, 2).defaultTo(0)66 table.integer('numberOfVotes').defaultTo(0)67 table.decimal('tmdbVoteAverage', 10, 2).defaultTo(0)68 table.integer('tmdbNumberOfVotes').defaultTo(0)69 table.string('status')70 table.date('releaseDate')71 table.integer('runtimeInMinutes')72 table.string('budget')73 table.decimal('revenue', 16, 2)74 table.string('posterPath')75 table.string('backdropPath')76 table.string('tmdbId').unique()77 table.string('imdbId').unique()78 table.timestamp('createdAt').defaultTo(knex.fn.now())79 table.timestamp('updatedAt').nullable()80 })81 }82 if (!await knex.schema.hasTable('tv_shows')) {83 await knex.schema.createTable('tv_shows', table => {84 table.uuid('id').primary()85 table.uuid('ratingId').references('ratings.id')86 table.string('title').unique()87 table.string('tagline')88 table.string('description', 10000)89 table.decimal('voteAverage', 10, 2).defaultTo(0)90 table.integer('numberOfVotes').defaultTo(0)91 table.decimal('tmdbVoteAverage', 10, 2).defaultTo(0)92 table.integer('tmdbNumberOfVotes').defaultTo(0).defaultTo(0)93 table.string('status')94 table.date('firstAirDate')95 table.date('lastAirDate').nullable()96 table.boolean('inProduction').defaultTo(false)97 table.integer('runtimeInMinutes')98 table.string('posterPath')99 table.string('backdropPath')100 table.string('tmdbId').unique()101 table.timestamp('createdAt').defaultTo(knex.fn.now())102 table.timestamp('updatedAt').nullable()103 })104 }105 if (!await knex.schema.hasTable('tv_seasons')) {106 await knex.schema.createTable('tv_seasons', table => {107 table.uuid('id').primary()108 table.uuid('tvShowId').references('tv_shows.id')109 table.date('airDate')110 table.string('title')111 table.string('description', 10000)112 table.integer('seasonNumber')113 table.string('posterPath')114 table.decimal('voteAverage', 10, 2).defaultTo(0)115 table.integer('numberOfVotes').defaultTo(0)116 table.string('tmdbId').unique()117 table.timestamp('createdAt').defaultTo(knex.fn.now())118 table.timestamp('updatedAt').nullable()119 })120 }121 if (!await knex.schema.hasTable('tv_episodes')) {122 await knex.schema.createTable('tv_episodes', table => {123 table.uuid('id').primary()124 table.uuid('seasonId').references('tv_seasons.id')125 table.date('airDate')126 table.integer('episodeNumber')127 table.string('name')128 table.string('description', 10000)129 table.string('posterPath')130 table.decimal('voteAverage', 10, 2).defaultTo(0)131 table.integer('numberOfVotes').defaultTo(0)132 table.decimal('tmdbVoteAverage', 10, 2).defaultTo(0)133 table.integer('tmdbNumberOfVotes').defaultTo(0)134 table.string('tmdbId')135 table.timestamp('createdAt').defaultTo(knex.fn.now())136 table.timestamp('updatedAt').nullable()137 })138 }139 if (!await knex.schema.hasTable('movies_production_companies')) {140 await knex.schema.createTable('movies_production_companies', table => {141 table.uuid('movieId').references('movies.id')142 table.uuid('productionCompanyId').references('production_companies.id')143 })144 }145 if (!await knex.schema.hasTable('movies_languages')) {146 await knex.schema.createTable('movies_languages', table => {147 table.uuid('movieId').references('movies.id')148 table.uuid('languageId').references('languages.id')149 })150 }151 if (!await knex.schema.hasTable('tv_shows_languages')) {152 await knex.schema.createTable('tv_shows_languages', table => {153 table.uuid('tvShowId').references('tv_shows.id')154 table.uuid('languageId').references('languages.id')155 })156 }157 if (!await knex.schema.hasTable('movies_genres')) {158 await knex.schema.createTable('movies_genres', table => {159 table.uuid('movieId').references('movies.id')160 table.uuid('genreId').references('movie_genres.id')161 })162 }163 if (!await knex.schema.hasTable('tv_shows_genres')) {164 await knex.schema.createTable('tv_shows_genres', table => {165 table.uuid('tvShowId').references('tv_shows.id')166 table.uuid('genreId').references('tv_show_genres.id')167 })168 }169 if (!await knex.schema.hasTable('actors')) {170 await knex.schema.createTable('actors', table => {171 table.uuid('id').primary()172 table.string('name').unique()173 table.boolean('gender')174 table.date('birthDate').nullable()175 table.string('placeOfBirth')176 table.string('biography', 5000)177 table.string('profilePhotoPath')178 table.string('tmdbId').unique()179 table.string('imdbId').unique()180 table.timestamp('createdAt').defaultTo(knex.fn.now())181 table.timestamp('updatedAt').nullable()182 })183 }184 if (!await knex.schema.hasTable('directors')) {185 await knex.schema.createTable('directors', table => {186 table.uuid('id').primary()187 table.string('name').unique()188 table.boolean('gender')189 table.date('birthDate').nullable()190 table.string('placeOfBirth')191 table.string('biography', 5000)192 table.string('profilePhotoPath')193 table.string('tmdbId').unique()194 table.string('imdbId').unique()195 table.timestamp('createdAt').defaultTo(knex.fn.now())196 table.timestamp('updatedAt').nullable()197 })198 }199 if (!await knex.schema.hasTable('movies_actors')) {200 await knex.schema.createTable('movies_actors', table => {201 table.uuid('movieId').references('movies.id')202 table.uuid('actorId').references('actors.id')203 })204 }205 if (!await knex.schema.hasTable('movies_directors')) {206 await knex.schema.createTable('movies_directors', table => {207 table.uuid('movieId').references('movies.id')208 table.uuid('directorId').references('directors.id')209 })210 }211 if (!await knex.schema.hasTable('tv_shows_actors')) {212 await knex.schema.createTable('tv_shows_actors', table => {213 table.uuid('tvShowId').references('tv_shows.id')214 table.uuid('actorId').references('actors.id')215 })216 }217 if (!await knex.schema.hasTable('tv_shows_directors')) {218 await knex.schema.createTable('tv_shows_directors', table => {219 table.uuid('tvShowId').references('tv_shows.id')220 table.uuid('directorId').references('directors.id')221 })222 }223 if (!await knex.schema.hasTable('tv_episodes_actors')) {224 await knex.schema.createTable('tv_episodes_actors', table => {225 table.uuid('tvEpisodeId').references('tv_episodes.id')226 table.uuid('actorId').references('actors.id')227 })228 }229 if (!await knex.schema.hasTable('tv_episodes_directors')) {230 await knex.schema.createTable('tv_episodes_directors', table => {231 table.uuid('tvEpisodeId').references('tv_episodes.id')232 table.uuid('directorId').references('directors.id')233 })234 }235 if (!await knex.schema.hasTable('tv_shows_production_companies')) {236 await knex.schema.createTable('tv_shows_production_companies', table => {237 table.uuid('tvShowId').references('tv_shows.id')238 table.uuid('productionCompanyId').references('production_companies.id')239 })240 }241}242export const down = async (knex) => {243 if (await knex.schema.hasTable('tv_shows_production_companies')) {244 await knex.schema.dropTable('tv_shows_production_companies')245 }246 if (await knex.schema.hasTable('tv_episodes_directors')) {247 await knex.schema.dropTable('tv_episodes_directors')248 }249 if (await knex.schema.hasTable('tv_episodes_actors')) {250 await knex.schema.dropTable('tv_episodes_actors')251 }252 if (await knex.schema.hasTable('tv_shows_directors')) {253 await knex.schema.dropTable('tv_shows_directors')254 }255 if (await knex.schema.hasTable('tv_shows_actors')) {256 await knex.schema.dropTable('tv_shows_actors')257 }258 if (await knex.schema.hasTable('movies_directors')) {259 await knex.schema.dropTable('movies_directors')260 }261 if (await knex.schema.hasTable('movies_actors')) {262 await knex.schema.dropTable('movies_actors')263 }264 if (await knex.schema.hasTable('directors')) {265 await knex.schema.dropTable('directors')266 }267 if (await knex.schema.hasTable('actors')) {268 await knex.schema.dropTable('actors')269 }270 if (await knex.schema.hasTable('tv_shows_genres')) {271 await knex.schema.dropTable('tv_shows_genres')272 }273 if (await knex.schema.hasTable('movies_genres')) {274 await knex.schema.dropTable('movies_genres')275 }276 if (await knex.schema.hasTable('tv_shows_languages')) {277 await knex.schema.dropTable('tv_shows_languages')278 }279 if (await knex.schema.hasTable('movies_languages')) {280 await knex.schema.dropTable('movies_languages')281 }282 if (await knex.schema.hasTable('movies_production_companies')) {283 await knex.schema.dropTable('movies_production_companies')284 }285 if (await knex.schema.hasTable('tv_episodes')) {286 await knex.schema.dropTable('tv_episodes')287 }288 if (await knex.schema.hasTable('tv_seasons')) {289 await knex.schema.dropTable('tv_seasons')290 }291 if (await knex.schema.hasTable('tv_shows')) {292 await knex.schema.dropTable('tv_shows')293 }294 if (await knex.schema.hasTable('movies')) {295 await knex.schema.dropTable('movies')296 }297 if (await knex.schema.hasTable('tv_show_genres')) {298 await knex.schema.dropTable('tv_show_genres')299 }300 if (await knex.schema.hasTable('movie_genres')) {301 await knex.schema.dropTable('movie_genres')302 }303 if (await knex.schema.hasTable('production_companies')) {304 await knex.schema.dropTable('production_companies')305 }306 if (await knex.schema.hasTable('ratings')) {307 await knex.schema.dropTable('ratings')308 }309 if (await knex.schema.hasTable('languages')) {310 await knex.schema.dropTable('languages')311 }312 if (await knex.schema.hasTable('countries')) {313 await knex.schema.dropTable('countries')314 }...

Full Screen

Full Screen

20171223203915_create_tables.js

Source:20171223203915_create_tables.js Github

copy

Full Screen

1exports.up = async function(knex, Promise) {2 if (! await knex.schema.hasTable("threads")) {3 await knex.schema.createTable("threads", table => {4 table.string("id", 36).notNullable().primary();5 table.integer("status").unsigned().notNullable().index();6 table.integer("is_legacy").unsigned().notNullable();7 table.string("user_id", 20).notNullable().index();8 table.string("user_name", 128).notNullable();9 table.string("channel_id", 20).nullable().unique();10 table.dateTime("created_at").notNullable().index();11 });12 }1314 if (! await knex.schema.hasTable("thread_messages")) {15 await knex.schema.createTable("thread_messages", table => {16 table.increments("id");17 table.string("thread_id", 36).notNullable().index().references("id").inTable("threads").onDelete("CASCADE");18 table.integer("message_type").unsigned().notNullable();19 table.string("user_id", 20).nullable();20 table.string("user_name", 128).notNullable();21 table.mediumtext("body").notNullable();22 table.integer("is_anonymous").unsigned().notNullable();23 table.string("dm_message_id", 20).nullable().unique();24 table.dateTime("created_at").notNullable().index();25 });26 }2728 if (! await knex.schema.hasTable("blocked_users")) {29 await knex.schema.createTable("blocked_users", table => {30 table.string("user_id", 20).primary().notNullable();31 table.string("user_name", 128).notNullable();32 table.string("blocked_by", 20).nullable();33 table.dateTime("blocked_at").notNullable();34 });35 }3637 if (! await knex.schema.hasTable("snippets")) {38 await knex.schema.createTable("snippets", table => {39 table.string("trigger", 32).primary().notNullable();40 table.text("body").notNullable();41 table.integer("is_anonymous").unsigned().notNullable();42 table.string("created_by", 20).nullable();43 table.dateTime("created_at").notNullable();44 });45 }46};4748exports.down = async function(knex, Promise) {49 if (await knex.schema.hasTable("thread_messages")) {50 await knex.schema.dropTable("thread_messages");51 }5253 if (await knex.schema.hasTable("threads")) {54 await knex.schema.dropTable("threads");55 }5657 if (await knex.schema.hasTable("blocked_users")) {58 await knex.schema.dropTable("blocked_users");59 }6061 if (await knex.schema.hasTable("snippets")) {62 await knex.schema.dropTable("snippets");63 } ...

Full Screen

Full Screen

test_helpers.js

Source:test_helpers.js Github

copy

Full Screen

...3export async function setupTest() {4 createLoaders()5 let i = 06 while (i++ < 10) {7 const results = [await r.knex.schema.hasTable('assignment'),8 await r.knex.schema.hasTable('campaign'),9 await r.knex.schema.hasTable('campaign_contact'),10 await r.knex.schema.hasTable('canned_response'),11 await r.knex.schema.hasTable('interaction_step'),12 await r.knex.schema.hasTable('invite'),13 await r.knex.schema.hasTable('job_request'),14 await r.knex.schema.hasTable('log'),15 await r.knex.schema.hasTable('message'),16 await r.knex.schema.hasTable('migrations'),17 await r.knex.schema.hasTable('opt_out'),18 await r.knex.schema.hasTable('organization'),19 await r.knex.schema.hasTable('pending_message_part'),20 await r.knex.schema.hasTable('question_response'),21 await r.knex.schema.hasTable('user'),22 await r.knex.schema.hasTable('user_cell'),23 await r.knex.schema.hasTable('user_organization'),24 await r.knex.schema.hasTable('zip_code')]25 if (results.some((element) => !element)) {26 await sleep(1000)27 }28 else {29 break30 }31 }32}33export async function cleanupTest() {34 // Drop tables in an order that drops foreign keys before dependencies35 await r.knex.schema.dropTableIfExists('log')36 await r.knex.schema.dropTableIfExists('zip_code')37 await r.knex.schema.dropTableIfExists('message')38 await r.knex.schema.dropTableIfExists('user_cell')...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { test, expect } from '@playwright/test';2import { launch } from 'qawolf';3test.describe('test', () => {4 let browser;5 let page;6 test.beforeAll(async () => {7 browser = await launch();8 });9 test.beforeEach(async () => {10 page = await browser.newPage();11 });12 test.afterAll(async () => {13 await browser.close();14 });15 test('test', async () => {16 const result = await page.evaluate(() => {17 return knex.schema.hasTable('users');18 });19 expect(result).toBe(true);20 });21});22import { test, expect } from '@playwright/test';23import { launch } from 'qawolf';24test.describe('test', () => {25 let browser;26 let page;27 test.beforeAll(async () => {28 browser = await launch();29 });30 test.beforeEach(async () => {31 page = await browser.newPage();32 });33 test.afterAll(async () => {34 await browser.close();35 });36 test('test', async () => {37 const result = await page.evaluate(() => {38 return knex.schema.hasTable('users');39 });40 expect(result).toBe(true);41 });42});43const request = require('supertest');44const app = require('../../app');45describe('GET /api/v1/users', () => {46 it('should return all users', () => {47 request(app)48 .get('/api/v1/users')49 .set('Authorization', 'Bearer ' + token)50 .then((res) => {51 expect(res.statusCode).toEqual(200);52 });53 });54});55const jwt = require('jsonwebtoken');56const User = require('../../models/userModel');57const userOneId = new mongoose.Types.ObjectId();58const userOne = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("../selectors/test");3describe('test', () => {4 let browser;5 beforeAll(async () => {6 browser = await qawolf.launch();7 });8 afterAll(async () => {9 await qawolf.stopVideos();10 await browser.close();11 });12 it('test', async () => {13 const page = await browser.newPage();14 await qawolf.register(page);15 await page.click(selectors["#root > div > div > div

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createPage } = require('@qawolf/web');2const { describe, expect, test } = require('@qawolf/jest');3const { hasTable } = require('@qawolf/knex');4describe('test', () => {5 let page;6 beforeAll(async () => {7 page = await createPage();8 });9 afterAll(async () => {10 await page.close();11 });12 test('test', async () => {13 const { context } = page;14 const hasTable = await hasTable(context, 'table');15 expect(hasTable).toBe(true);16 });17});18const { createPage } = require('@qawolf/web');19const { describe, expect, test } = require('@qawolf/jest');20const { hasTable } = require('@qawolf/knex');21describe('test', () => {22 let page;23 beforeAll(async () => {24 page = await createPage();25 });26 afterAll(async () => {27 await page.close();28 });29 test('test', async () => {30 const { context } = page;31 const hasTable = await hasTable(context, 'table');32 expect(hasTable).toBe(true);33 });34});35const { createPage } = require('@qawolf/web');36const { describe, expect, test } = require('@qawolf/jest');37const { hasTable } = require('@qawolf/knex');38describe('test', () => {39 let page;40 beforeAll(async () => {41 page = await createPage();42 });43 afterAll(async () => {44 await page.close();45 });46 test('test', async () => {47 const { context } = page;48 const hasTable = await hasTable(context, 'table');49 expect(hasTable).toBe(true);50 });51});

Full Screen

Using AI Code Generation

copy

Full Screen

1const knex = require('knex');2const config = require('../knexfile.js');3const db = knex(config.development);4module.exports = {5}6async function checkTable(table) {7 const exists = await db.schema.hasTable(table);8 return exists;9}10require('dotenv').config();11module.exports = {12 development: {13 connection: {14 },15 migrations: {16 },17 seeds: {18 }19 }20}21const { checkTable } = require('./test');22describe('Test', () => {23 it('Check Table', async () => {24 const result = await checkTable('users');25 expect(result).toBe(true);26 });27});28"scripts": {29},

Full Screen

Using AI Code Generation

copy

Full Screen

1const knex = require("knex");2qawolf.create();3const db = knex({4 connection: {5 },6});7const tableExists = await db.schema.hasTable("table_name");8if (tableExists) {9 console.log("Table exists");10} else {11 await db.schema.createTable("table_name", (table) => {12 table.increments("id");13 table.string("name");14 table.integer("age");15 });16 console.log("Table created");17}18await qawolf.stop();19const qawolf = require("qawolf");20describe("test", () => {21 let browser;22 beforeAll(async () => {23 browser = await qawolf.launch();24 });25 afterAll(async () => {26 await qawolf.stopVideos();27 await browser.close();28 });29 it("test", async () => {30 const context = await browser.newContext();31 const page = await context.newPage();32 await qawolf.create();33 const db = await page.evaluateHandle(() => {34 return knex({35 connection: {36 },37 });38 });39 const tableExists = await db.evaluate((db) =>40 db.schema.hasTable("table_name")41 );42 if (tableExists) {43 console.log("Table exists");44 } else {45 await db.evaluate((db) =>46 db.schema.createTable("table_name", (table) => {47 table.increments("id");48 table.string("name");49 table.integer("age");50 })51 );52 console.log("Table created");53 }54 await qawolf.stop();55 await context.close();56 });57});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful