Change a column type from Date to DateTime during ROR migration

jdog

I need to change my column type from date to datetime for an app I am making. I don't care about the data as its still being developed.

How can I do this?

apneadiving

First in your terminal:

rails g migration change_date_format_in_my_table

Then in your migration file:

For Rails >= 3.2:

class ChangeDateFormatInMyTable < ActiveRecord::Migration
  def up
    change_column :my_table, :my_column, :datetime
  end

  def down
    change_column :my_table, :my_column, :date
  end
end

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Laravel4 migration column type of Date of Birth

分類Dev

Convert the column type from object to date format - python

分類Dev

Change column type in a materialized view

分類Dev

How to change the time of a Pandas datetime column to midnight?

分類Dev

Django NodeNotFoundError during migration

分類Dev

Rails change column type and update column values

分類Dev

Rake DB:Migration error when modifying the column type

分類Dev

How to change column names in a R script during runtime?

分類Dev

Extract Only Date from DateTime Object in Javascript?

分類Dev

Extract date from datetime dictionary in django queryset

分類Dev

Pandas - Converting column of type float to date time

分類Dev

Excel: How to change the date column to display only Month of the date?

分類Dev

Change the type of a dataframe's column in r?

分類Dev

How to change background colour of column based upon column header date

分類Dev

Enterprise Architect Date format for storing DateTime type tagged value

分類Dev

Change day of DateTime object using values in pandas dataframe column

分類Dev

How to convert efficiently a dataframe column of string type into datetime in Python?

分類Dev

Npgsql, error during saving a DateTime value (null value in column "CreatedAt" violates not-null constraint)

分類Dev

Getting date from Django datetime field with F() expression

分類Dev

How to get only date from a DateTime value in Razor page?

分類Dev

Get offset from datetime string and apply to a new date object

分類Dev

sql query select date equal rows from datetime

分類Dev

Generating a Stata date variable from ISO datetime string

分類Dev

how to reindex ref column from sorting a date column?

分類Dev

Python: How to convert Pyspark column to date type if there are null values

分類Dev

Changing a column type from integer to string

分類Dev

Putting the column type from the DB to a XML attribute

分類Dev

Change values from one column higher than X but not change the others

分類Dev

Crystal reports SQL Expression to extract Year from a DateTime column

Related 関連記事

  1. 1

    Laravel4 migration column type of Date of Birth

  2. 2

    Convert the column type from object to date format - python

  3. 3

    Change column type in a materialized view

  4. 4

    How to change the time of a Pandas datetime column to midnight?

  5. 5

    Django NodeNotFoundError during migration

  6. 6

    Rails change column type and update column values

  7. 7

    Rake DB:Migration error when modifying the column type

  8. 8

    How to change column names in a R script during runtime?

  9. 9

    Extract Only Date from DateTime Object in Javascript?

  10. 10

    Extract date from datetime dictionary in django queryset

  11. 11

    Pandas - Converting column of type float to date time

  12. 12

    Excel: How to change the date column to display only Month of the date?

  13. 13

    Change the type of a dataframe's column in r?

  14. 14

    How to change background colour of column based upon column header date

  15. 15

    Enterprise Architect Date format for storing DateTime type tagged value

  16. 16

    Change day of DateTime object using values in pandas dataframe column

  17. 17

    How to convert efficiently a dataframe column of string type into datetime in Python?

  18. 18

    Npgsql, error during saving a DateTime value (null value in column "CreatedAt" violates not-null constraint)

  19. 19

    Getting date from Django datetime field with F() expression

  20. 20

    How to get only date from a DateTime value in Razor page?

  21. 21

    Get offset from datetime string and apply to a new date object

  22. 22

    sql query select date equal rows from datetime

  23. 23

    Generating a Stata date variable from ISO datetime string

  24. 24

    how to reindex ref column from sorting a date column?

  25. 25

    Python: How to convert Pyspark column to date type if there are null values

  26. 26

    Changing a column type from integer to string

  27. 27

    Putting the column type from the DB to a XML attribute

  28. 28

    Change values from one column higher than X but not change the others

  29. 29

    Crystal reports SQL Expression to extract Year from a DateTime column

ホットタグ

アーカイブ