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

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?