Magento 2.3.0: How to add TIMESTAMP_INIT as a default value in declarative schema?How to Upgrade magento version from 2.2.X to 2.3.0?Magento 2.3 : How to implement declarative schema in custom moduleMagento 2.3.0 not workingIssue with Magento 2.3.0 InstallationMagento 2.3.0 stucks at 50%How to drop a table in Declarative schema?Magento 2.3.0 — Shipping Method FetchingMagento 2.3.0 Performance issueHow to solve Unknown hashing algorithm: md5 in Magento 2.3.0?Drop column on declarative schema not working as expected

Question about exercise 11.5 in TeXbook

What does uniform continuity mean exactly?

What does the behaviour of water on the skin of an aircraft in flight tell us?

Restoring order in a deck of playing cards

Do firearms count as ranged weapons?

Split polygon using another polygon in QGIS

Ticket sales for Queen at the Live Aid

Infinitely many hats

Is my router's IP address really public?

Can a non-EU citizen travel within schengen zone freely without passport?

How could Catholicism have incorporated witchcraft into its dogma?

What are the problems in teaching guitar via Skype?

Is this story about US tax office reasonable?

Is it possible to change original filename of an exe?

Plot exactly N bounce of a ball

Tic-Tac-Toe for the terminal

How to properly maintain eye contact with people that have distinct facial features?

Can the Help action be used to give advantage to a specific ally's attack (rather than just the next ally who attacks the target)?

Uses of T extends U?

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

What are these (utility?) boxes at the side of the house?

File globbing pattern, !(*example), behaves differently in bash script than it does in bash shell

Why did this prime-sequence puzzle not work?

How can I find where certain bash function is defined?



Magento 2.3.0: How to add TIMESTAMP_INIT as a default value in declarative schema?


How to Upgrade magento version from 2.2.X to 2.3.0?Magento 2.3 : How to implement declarative schema in custom moduleMagento 2.3.0 not workingIssue with Magento 2.3.0 InstallationMagento 2.3.0 stucks at 50%How to drop a table in Declarative schema?Magento 2.3.0 — Shipping Method FetchingMagento 2.3.0 Performance issueHow to solve Unknown hashing algorithm: md5 in Magento 2.3.0?Drop column on declarative schema not working as expected






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















As I'm adding CURRENT_TIMESTAMP as a default value for created_datetime
and updated_datetime columns in my database table named faqs, I'm getting both the columns updated while edit the FAQ in admin form.



I want to update timestamp only for updated_datetime column. So for that I'm trying to add TIMESTAMP_INIT as a default value for created_datetime column and TIMESTAMP_INIT_UPDATE for updated_datetime column as described follows:




appcodeNamespaceModuleetcdb_schema.xml




<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="faqs" resource="default" engine="innodb" comment="FAQ Table">
........
<column xsi:type="timestamp" name="created_datetime" nullable="false" default="TIMESTAMP_INIT" comment="Created Datetime"/>
<column xsi:type="timestamp" name="updated_datetime" nullable="false" default="TIMESTAMP_INIT_UPDATE" comment="Updated Datetime"/>
........
</table>
</schema>


While running php bin/magento setup:upgrade command in cmd, I'm getting following error:



Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
Line: 12
Element 'column', attribute 'default': 'TIMESTAMP_INIT' is not a valid value of the atomic type 'defaults'.
Line: 12
Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT_UPDATE' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
Line: 13
Element 'column', attribute 'default': 'TIMESTAMP_INIT_UPDATE' is not a valid value of the atomic type 'defaults'.
Line: 13


Can anyone please help me to correct the syntax or guide me how to achieve this in db_schema.xml? Thanks in anticipation.










share|improve this question




























    1















    As I'm adding CURRENT_TIMESTAMP as a default value for created_datetime
    and updated_datetime columns in my database table named faqs, I'm getting both the columns updated while edit the FAQ in admin form.



    I want to update timestamp only for updated_datetime column. So for that I'm trying to add TIMESTAMP_INIT as a default value for created_datetime column and TIMESTAMP_INIT_UPDATE for updated_datetime column as described follows:




    appcodeNamespaceModuleetcdb_schema.xml




    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="faqs" resource="default" engine="innodb" comment="FAQ Table">
    ........
    <column xsi:type="timestamp" name="created_datetime" nullable="false" default="TIMESTAMP_INIT" comment="Created Datetime"/>
    <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="TIMESTAMP_INIT_UPDATE" comment="Updated Datetime"/>
    ........
    </table>
    </schema>


    While running php bin/magento setup:upgrade command in cmd, I'm getting following error:



    Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
    Line: 12
    Element 'column', attribute 'default': 'TIMESTAMP_INIT' is not a valid value of the atomic type 'defaults'.
    Line: 12
    Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT_UPDATE' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
    Line: 13
    Element 'column', attribute 'default': 'TIMESTAMP_INIT_UPDATE' is not a valid value of the atomic type 'defaults'.
    Line: 13


    Can anyone please help me to correct the syntax or guide me how to achieve this in db_schema.xml? Thanks in anticipation.










    share|improve this question
























      1












      1








      1








      As I'm adding CURRENT_TIMESTAMP as a default value for created_datetime
      and updated_datetime columns in my database table named faqs, I'm getting both the columns updated while edit the FAQ in admin form.



      I want to update timestamp only for updated_datetime column. So for that I'm trying to add TIMESTAMP_INIT as a default value for created_datetime column and TIMESTAMP_INIT_UPDATE for updated_datetime column as described follows:




      appcodeNamespaceModuleetcdb_schema.xml




      <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
      <table name="faqs" resource="default" engine="innodb" comment="FAQ Table">
      ........
      <column xsi:type="timestamp" name="created_datetime" nullable="false" default="TIMESTAMP_INIT" comment="Created Datetime"/>
      <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="TIMESTAMP_INIT_UPDATE" comment="Updated Datetime"/>
      ........
      </table>
      </schema>


      While running php bin/magento setup:upgrade command in cmd, I'm getting following error:



      Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
      Line: 12
      Element 'column', attribute 'default': 'TIMESTAMP_INIT' is not a valid value of the atomic type 'defaults'.
      Line: 12
      Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT_UPDATE' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
      Line: 13
      Element 'column', attribute 'default': 'TIMESTAMP_INIT_UPDATE' is not a valid value of the atomic type 'defaults'.
      Line: 13


      Can anyone please help me to correct the syntax or guide me how to achieve this in db_schema.xml? Thanks in anticipation.










      share|improve this question














      As I'm adding CURRENT_TIMESTAMP as a default value for created_datetime
      and updated_datetime columns in my database table named faqs, I'm getting both the columns updated while edit the FAQ in admin form.



      I want to update timestamp only for updated_datetime column. So for that I'm trying to add TIMESTAMP_INIT as a default value for created_datetime column and TIMESTAMP_INIT_UPDATE for updated_datetime column as described follows:




      appcodeNamespaceModuleetcdb_schema.xml




      <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
      <table name="faqs" resource="default" engine="innodb" comment="FAQ Table">
      ........
      <column xsi:type="timestamp" name="created_datetime" nullable="false" default="TIMESTAMP_INIT" comment="Created Datetime"/>
      <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="TIMESTAMP_INIT_UPDATE" comment="Updated Datetime"/>
      ........
      </table>
      </schema>


      While running php bin/magento setup:upgrade command in cmd, I'm getting following error:



      Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
      Line: 12
      Element 'column', attribute 'default': 'TIMESTAMP_INIT' is not a valid value of the atomic type 'defaults'.
      Line: 12
      Element 'column', attribute 'default': [facet 'enumeration'] The value 'TIMESTAMP_INIT_UPDATE' is not an element of the set 'CURRENT_TIMESTAMP', '0', 'NULL'.
      Line: 13
      Element 'column', attribute 'default': 'TIMESTAMP_INIT_UPDATE' is not a valid value of the atomic type 'defaults'.
      Line: 13


      Can anyone please help me to correct the syntax or guide me how to achieve this in db_schema.xml? Thanks in anticipation.







      magento2.3.0 datetime database-schema






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 22 at 11:29









      Dhara BhattiDhara Bhatti

      169112




      169112




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml




          appcodeNamespaceModuleetcdb_schema.xml




          <column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
          <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>


          Hope it help!






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f275666%2fmagento-2-3-0-how-to-add-timestamp-init-as-a-default-value-in-declarative-schem%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml




            appcodeNamespaceModuleetcdb_schema.xml




            <column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
            <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>


            Hope it help!






            share|improve this answer



























              1














              You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml




              appcodeNamespaceModuleetcdb_schema.xml




              <column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
              <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>


              Hope it help!






              share|improve this answer

























                1












                1








                1







                You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml




                appcodeNamespaceModuleetcdb_schema.xml




                <column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
                <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>


                Hope it help!






                share|improve this answer













                You have to need update created_datetime and updated_datetime with on_update="false" and on_update="true" in db_schema.xml




                appcodeNamespaceModuleetcdb_schema.xml




                <column xsi:type="timestamp" name="created_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created Datetime"/>
                <column xsi:type="timestamp" name="updated_datetime" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated Datetime"/>


                Hope it help!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 22 at 11:56









                Kirti NariyaKirti Nariya

                1,353517




                1,353517



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f275666%2fmagento-2-3-0-how-to-add-timestamp-init-as-a-default-value-in-declarative-schem%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form