Skip to content

Unable to import schema action javascript #54

@albrm

Description

@albrm

Screen Shot 2022-04-11 at 15 18 06

insert into qore_engine_migrations ("name", "description", "schema", "created_at", "up", "down", "active") values ('Create Column check_date_available (action) in table Draft_Appointment', 'null', '{"resource":"Column","migration":{"name":"check_date_available","table":"Draft_Appointment","column":{"type":"action","definition":{"action":"JavaScript","function":"const axios = require('axios')\nconst ERRORS = []\nconst url = 'https://staging-qore-data-teacher-593643.qore.dev'\nconst headers = {\n    accept: '*/*',\n    'x-qore-engine-admin-secret': 'UM5MlKofJjxhC0KQejD8WZi2cmbpAN5A',\n}\n\nconst getTimeSlot = async (id) => {\n    try {\n        const response = await axios({\n            method: 'get',\n            headers,\n            url: `${url}/v1/table/Service_Pool_Slot/row/${id}`,\n        })\n        return response.data\n    } catch (error) {\n        const { response } = error\n        if (!response) throw new Error(response)\n        else ERRORS.push(response.statusText)\n    }\n}\n\nconst checkTicket = async (date, time, storeId) => {\n    const formatedDate = date.slice(0, 10).replaceAll('/', '-')\n    try {\n        const { data } = await axios({\n            method: 'get',\n            headers,\n            url: `${url}/v1/table/Service_Pool_Ticket`,\n        })\n\n        const ticket = data.items.find(\n            (ticket) =>\n                ticket.date === formatedDate &&\n                ticket.time === time &&\n                ticket.service_place_ticket === storeId,\n        )\n\n        return ticket ? 'not available' : 'available'\n    } catch (error) {\n        const { response } = error\n        if (!response) throw new Error(response)\n        else ERRORS.push(response.statusText)\n    }\n}\n\nasync function main(user, row, client, args) {\n    const input = {\n        status: 'Waiting',\n        date: '2022-04-04',\n        service_place_appointment: 1,\n    }\n    const slot = await getTimeSlot(1)\n    const isAvailable = await checkTicket(\n        input.date,\n        slot.name,\n        input.service_place_appointment,\n    )\n\n    return isAvailable\n}\n","nullable":true}},"description":""},"operation":"Create"}', '2022-04-08T03:14:12.000Z', 'insert into "qore_engine_columns" ("active", "created_at", "definition", "deletion_protection", "description", "enums", "field_type", "id", "is_not_null", "is_unique", "metadata", "name", "table_id", "updated_at") values (true, ''2022-04-08T03:14:12.242Z'',  E''{"definition":{"action":"JavaScript","function":"const axios = require(''''axios'''')\\nconst ERRORS = []\\nconst url = ''''https://staging-qore-data-teacher-593643.qore.dev''''\\nconst headers = {\\n    accept: ''''*/*'''',\\n    ''''x-qore-engine-admin-secret'''': ''''UM5MlKofJjxhC0KQejD8WZi2cmbpAN5A'''',\\n}\\n\\nconst getTimeSlot = async (id) => {\\n    try {\\n        const response = await axios({\\n            method: ''''get'''',\\n            headers,\\n            url: `${url}/v1/table/Service_Pool_Slot/row/${id}`,\\n        })\\n        return response.data\\n    } catch (error) {\\n        const { response } = error\\n        if (!response) throw new Error(response)\\n        else ERRORS.push(response.statusText)\\n    }\\n}\\n\\nconst checkTicket = async (date, time, storeId) => {\\n    const formatedDate = date.slice(0, 10).replaceAll(''''/'''', ''''-'''')\\n    try {\\n        const { data } = await axios({\\n            method: ''''get'''',\\n            headers,\\n            url: `${url}/v1/table/Service_Pool_Ticket`,\\n        })\\n\\n        const ticket = data.items.find(\\n            (ticket) =>\\n                ticket.date === formatedDate &&\\n                ticket.time === time &&\\n                ticket.service_place_ticket === storeId,\\n        )\\n\\n        return ticket ? ''''not available'''' : ''''available''''\\n    } catch (error) {\\n        const { response } = error\\n        if (!response) throw new Error(response)\\n        else ERRORS.push(response.statusText)\\n    }\\n}\\n\\nasync function main(user, row, client, args) {\\n    const input = {\\n        status: ''''Waiting'''',\\n        date: ''''2022-04-04'''',\\n        service_place_appointment: 1,\\n    }\\n    const slot = await getTimeSlot(1)\\n    const isAvailable = await checkTicket(\\n        input.date,\\n        slot.name,\\n        input.service_place_appointment,\\n    )\\n\\n    return isAvailable\\n}\\n","nullable":true},"type":"action"}'', true, '''', NULL, ''action'', ''d66a911c-cd81-496c-afb2-9514a623a528'', false, false, ''{"width":200}'', ''check_date_available'', ''4b85ad07-7d44-42ed-b11d-1187761e045d'', ''2022-04-08T03:14:12.242Z'') returning "id", "metadata", "is_not_null", "is_unique";
alter table "Draft_Appointment" add column "check_date_available" varchar(255) null default null;
', 'delete from "qore_engine_columns" where "table_id" = ''4b85ad07-7d44-42ed-b11d-1187761e045d'' and "name" = ''check_date_available'';
alter table "Draft_Appointment" drop column "check_date_available";
drop function if exists  cascade;', true);
insert into "qore_engine_columns" ("active", "created_at", "definition", "deletion_protection", "description", "enums", "field_type", "id", "is_not_null", "is_unique", "metadata", "name", "table_id", "updated_at") values (true, '2022-04-08T03:14:12.242Z',  E'{"definition":{"action":"JavaScript","function":"const axios = require(''axios'')\\nconst ERRORS = []\\nconst url = ''https://staging-qore-data-teacher-593643.qore.dev''\\nconst headers = {\\n    accept: ''*/*'',\\n    ''x-qore-engine-admin-secret'': ''UM5MlKofJjxhC0KQejD8WZi2cmbpAN5A'',\\n}\\n\\nconst getTimeSlot = async (id) => {\\n    try {\\n        const response = await axios({\\n            method: ''get'',\\n            headers,\\n            url: `${url}/v1/table/Service_Pool_Slot/row/${id}`,\\n        })\\n        return response.data\\n    } catch (error) {\\n        const { response } = error\\n        if (!response) throw new Error(response)\\n        else ERRORS.push(response.statusText)\\n    }\\n}\\n\\nconst checkTicket = async (date, time, storeId) => {\\n    const formatedDate = date.slice(0, 10).replaceAll(''/'', ''-'')\\n    try {\\n        const { data } = await axios({\\n            method: ''get'',\\n            headers,\\n            url: `${url}/v1/table/Service_Pool_Ticket`,\\n        })\\n\\n        const ticket = data.items.find(\\n            (ticket) =>\\n                ticket.date === formatedDate &&\\n                ticket.time === time &&\\n                ticket.service_place_ticket === storeId,\\n        )\\n\\n        return ticket ? ''not available'' : ''available''\\n    } catch (error) {\\n        const { response } = error\\n        if (!response) throw new Error(response)\\n        else ERRORS.push(response.statusText)\\n    }\\n}\\n\\nasync function main(user, row, client, args) {\\n    const input = {\\n        status: ''Waiting'',\\n        date: ''2022-04-04'',\\n        service_place_appointment: 1,\\n    }\\n    const slot = await getTimeSlot(1)\\n    const isAvailable = await checkTicket(\\n        input.date,\\n        slot.name,\\n        input.service_place_appointment,\\n    )\\n\\n    return isAvailable\\n}\\n","nullable":true},"type":"action"}', true, '', NULL, 'action', 'd66a911c-cd81-496c-afb2-9514a623a528', false, false, '{"width":200}', 'check_date_available', '4b85ad07-7d44-42ed-b11d-1187761e045d', '2022-04-08T03:14:12.242Z') returning "id", "metadata", "is_not_null", "is_unique";
alter table "Draft_Appointment" add column "check_date_available" varchar(255) null default null; syntax error at or near "axios"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions