<?xml version="1.0"?>
<!--
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
-->

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
	<table name="writetextai_writetextai_products_store" resource="default" engine="innodb" comment="writetextai_writetextai_products_store Table">
		<column xsi:type="int" name="products_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
		<constraint xsi:type="primary" referenceId="PRIMARY">
			<column name="products_id"/>
		</constraint>
		<column name="product_id" nullable="false" xsi:type="int" comment="product_id" identity="false"/>
		<column name="store_id" nullable="false" xsi:type="varchar" comment="store_id" length="255"/>
		<column name="product_attributes_selected" nullable="true" xsi:type="text" comment="product_attributes_selected" />
        <column name="other_details_checked" nullable="true" xsi:type="int" comment="other_details_checked"/>
		<column name="other_details" nullable="false" xsi:type="varchar" comment="other_details" length="255"/>
        <column name="additional_prompt" nullable="true" xsi:type="text" comment="additional_prompt"/>
		<column name="generated_at" nullable="true" xsi:type="datetime" comment="generated_at"/>
		<column name="edited_at" nullable="true" xsi:type="datetime" comment="edited_at"/>
		<column name="transferred_at" nullable="true" xsi:type="datetime" comment="transferred_at"/>
        <column name="refresh_at" nullable="true" xsi:type="datetime" comment="refresh_at"/>
        <column name="reviewed_at" nullable="true" xsi:type="datetime" comment="reviewed_at"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_PRODUCTS_STORE_PRODUCT_ID_STORE_ID">
            <column name="product_id"/>
            <column name="store_id"/>
        </constraint>
	</table>

    <table name="writetextai_writetextai_categories_store" resource="default" engine="innodb" comment="writetextai_writetextai_categories_store Table">
		<column xsi:type="int" name="categories_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
		<constraint xsi:type="primary" referenceId="PRIMARY">
			<column name="categories_id"/>
		</constraint>
		<column name="category_id" nullable="true" xsi:type="int" comment="category_id" identity="false"/>
		<column name="store_id" nullable="true" xsi:type="varchar" comment="store_id" length="255"/>
		<column name="representative_products_selected" nullable="true" xsi:type="text" comment="representative_products_selected"/>
		<column name="other_details_checked" nullable="true" xsi:type="int" comment="other_details_checked"/>
		<column name="other_details" nullable="true" xsi:type="varchar" comment="other_details" length="255"/>
        <column name="additional_prompt" nullable="true" xsi:type="text" comment="additional_prompt"/>
		<column name="generated_at" nullable="true" xsi:type="datetime" comment="generated_at"/>
		<column name="edited_at" nullable="true" xsi:type="datetime" comment="edited_at"/>
		<column name="transferred_at" nullable="true" xsi:type="datetime" comment="transferred_at"/>
		<column name="refresh_at" nullable="true" xsi:type="datetime" comment="refresh_at"/>
        <column name="reviewed_at" nullable="true" xsi:type="datetime" comment="reviewed_at"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_CATEGORIES_STORE_CATEGORY_ID_STORE_ID">
            <column name="category_id"/>
            <column name="store_id"/>
        </constraint>
	</table>
    
	<table name="writetextai_writetextai_settings" resource="default" engine="innodb" comment="WriteTextAI Settings Table">
		<column name="setting_id" xsi:type="int" padding="10" unsigned="true" nullable="false" identity="true" comment="Setting Id"/>
		<column name="setting_name" nullable="true" xsi:type="varchar" length="255" comment="Setting name" />
		<column name="value" nullable="true" xsi:type="text" comment="Setting value" />
		<column name="etag" nullable="true" xsi:type="varchar" length="255" comment="Setting name" />
		<column name="locale" nullable="true" xsi:type="varchar" length="255" comment="Locale" />
		<constraint xsi:type="primary" referenceId="PRIMARY">
			<column name="setting_id"/>
		</constraint>
		<index referenceId="WRITETEXTAI_WRITETEXTAI_SETTINGS_SETTING_NAME" indexType="btree">
            <column name="setting_name"/>
        </index>
	</table>
    
    <table name="writetextai_writetextai_user_fields_selected" resource="default" engine="innodb" comment="writetextai_writetextai_user_fields_selected Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="value" nullable="false" xsi:type="text" comment="value"/>
        <column name="user_id" nullable="false" xsi:type="int" comment="user_id"/>
        <column name="field" nullable="false" xsi:type="varchar" comment="field" length="255"/>
        <column name="entity_type" nullable="true" default="" xsi:type="varchar" comment="entity_type" length="255"/>
        <column name="scope" nullable="true" default="" xsi:type="varchar" comment="scope" length="255"/>
        <column name="action_type" nullable="false" xsi:type="varchar" comment="deprecated" length="255"/>
        <column name="fields" nullable="false" xsi:type="text" comment="deprecated"/>
    </table>

    <table name="writetextai_writetextai_user_web_token" resource="default" engine="innodb" comment="writetextai_writetextai_user_web_token Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user_id" nullable="false" xsi:type="int" comment="user_id"/>
        <column name="token" nullable="false" xsi:type="text" comment="token"/>
        <column name="email" nullable="true" xsi:type="varchar" length="255" comment="email"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_USER_WEB_TOKEN_USER_ID">
            <column name="user_id"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_bulk_generate_requests" resource="default" engine="innodb" comment="writetextai_writetextai_bulk_generate_requests Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user" nullable="false" xsi:type="varchar" comment="user" length="255"/>
        <column name="request_id" nullable="false" xsi:type="varchar" length="255" comment="request_id"/>
        <column name="record_id" nullable="false" xsi:type="varchar" length="255" comment="record_id"/>
        <column name="store_id" nullable="false" xsi:type="varchar" length="255" comment="store_id"/>
        <column name="entity_type" nullable="false" xsi:type="varchar" length="255" comment="entity_type"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_BULK_GENERATE_REQUESTS_USER">
            <column name="user"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_full_automation_requests" resource="default" engine="innodb" comment="writetextai_writetextai_full_automation_requests Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user" nullable="false" xsi:type="varchar" comment="user" length="255"/>
        <column name="request_id" nullable="false" xsi:type="varchar" length="255" comment="request_id"/>
        <column name="record_id" nullable="false" xsi:type="varchar" length="255" comment="record_id"/>
        <column name="store_id" nullable="false" xsi:type="varchar" length="255" comment="store_id"/>
        <column name="entity_type" nullable="false" xsi:type="varchar" length="255" comment="entity_type"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_FULL_AUTOMATION_REQUESTS_USER">
            <column name="user"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_bulk_transfer_requests" resource="default" engine="innodb" comment="writetextai_writetextai_bulk_transfer_requests Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user" nullable="false" xsi:type="varchar" comment="user" length="255"/>
        <column name="queue_ids" nullable="false" xsi:type="text" comment="queue_ids"/>
        <column name="completed_ids" nullable="false" xsi:type="text" comment="completed_ids"/>
        <column name="success_ids" nullable="true" xsi:type="text" comment="success_ids"/>
        <column name="error_ids" nullable="true" xsi:type="text" comment="error_ids"/>
        <column name="skipped_ids" nullable="true" xsi:type="text" comment="skipped_ids"/>
        <column name="stores_selected" nullable="false" xsi:type="varchar" comment="stores_selected" length="255"/>
        <column name="fields_selected" nullable="false" xsi:type="varchar" comment="fields_selected" length="255"/>
        <column name="store_filter" nullable="false" xsi:type="varchar" comment="store_filter" length="255"/>
        <column name="is_cancelled" nullable="false" default="0" xsi:type="int" comment="is_cancelled"/>
        <column name="started_at" nullable="true" xsi:type="datetime" comment="started_at"/>
        <column name="transferred_at" nullable="true" xsi:type="datetime" comment="transferred_at"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_BULK_TRANSFER_REQUESTS_USER">
            <column name="user"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_bulk_keyword_analysis_requests" resource="default" engine="innodb" comment="writetextai_writetextai_bulk_keyword_analysis_requests Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user" nullable="false" xsi:type="varchar" comment="user" length="255"/>
        <column name="request_id" nullable="false" xsi:type="varchar" length="255" comment="request_id"/>
        <column name="record_id" nullable="false" xsi:type="varchar" length="255" comment="record_id"/>
        <column name="store_id" nullable="false" xsi:type="varchar" length="255" comment="store_id"/>
        <column name="entity_type" nullable="false" xsi:type="varchar" length="255" comment="entity_type"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_BULK_KEYWORD_ANALYSIS_REQUESTS_USER">
            <column name="user"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_user_feedback" resource="default" engine="innodb" comment="writetextai_writetextai_user_feedback Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="user_id" nullable="false" xsi:type="int" comment="user_id"/>
        <column name="feedback_id" nullable="false" xsi:type="varchar" length="255" comment="Feedback id"/>
        <constraint xsi:type="unique" referenceId="WRITETEXTAI_WRITETEXTAI_USER_FEEDBACK_USER_ID_FEEDBACK_ID">
            <column name="user_id"/>
            <column name="feedback_id"/>
        </constraint>
    </table>

    <table name="writetextai_writetextai_single_generate_requests" resource="default" engine="innodb" comment="writetextai_writetextai_single_generate_requests Table">
        <column xsi:type="int" name="single_generate_requests_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="single_generate_requests_id"/>
        </constraint>
        <column name="request_id" nullable="true" xsi:type="text" comment="request_id"/>
        <column name="record_id" nullable="true" xsi:type="varchar" comment="record_id" length="255"/>
        <column name="entity_type" nullable="true" xsi:type="varchar" comment="entity_type" length="255"/>
        <column name="store_id" nullable="true" xsi:type="varchar" comment="store_id" length="255"/>
		<column name="user" nullable="true" xsi:type="varchar" comment="user" length="255"/>
    </table>

    <table name="writetextai_writetextai_new_records" resource="default" engine="innodb" comment="writetextai_writetextai_new_records Table">
        <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Unique Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="id"/>
        </constraint>
        <column name="record_id" nullable="true" xsi:type="int" comment="record_id"/>
        <column name="entity_type" nullable="true" xsi:type="varchar" comment="entity_type" length="255"/>
        <column name="sku" nullable="true" xsi:type="varchar" comment="product_sku" length="255"/>
        <column name="email_sent" nullable="true" default="0" xsi:type="int" comment="email_sent"/>
        <column name="created_at" nullable="true" xsi:type="datetime" comment="created_at"/>
        <column name="updated_at" nullable="true" xsi:type="datetime" comment="updated_at"/>
    </table>
</schema>