I want to put a column in front of my table, I know what you can do
add_column :customer, :first_name, after: :last_name
but is there a way to do :before ?
:before
You can insert a column in front of the table using the :first parameter:
:first
add_column :table_name, :column_name, :column_type, first: true
You can use :after to handle all other positioning cases.
:after
These, incidentally, are mysql-specific options.
https://github.com/rails/rails/blob/80e66cc/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb#L50-L55 lists the available options, it seems that they only support before and first .
before
first
For what it's worth, PostgreSQL only supports adding columns to the end of the table.
Related questions: change table add ... before `code`?
Source: https://habr.com/ru/post/1258850/More articles:Is it possible to use patterns matching security devices in `while let`? - pattern-matchingJavaScript function doesn't work when used inside onclick attribute - javascriptXcode: Error Domain = DVTPlaygroundCommunicationErrorDomain Code = 1 - iosiOS 10 How do I view a list of pending notifications using UNUserNotificationCenter? - iosCocoa delegate nstabviewcontroller - cocoaUsing column heading and values ββfrom one data frame to find weights in another piece of data - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1258852/adding-unit-tests-to-a-f-project-in-vscode&usg=ALkJrhhsQjOPdFFHqC8gqIcmyivFFzS3oQhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1258853/how-to-pass-parameters-to-a-net-core-project-with-dockerfile&usg=ALkJrhipSSa0GE2P0vfrIU-m3Ih8h1-FCAKotlin delegates the future - javateamcity, how to see the final output of a custom script command line build step - teamcityAll Articles