|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +ActiveRecord::Schema.define do |
| 4 | + if connection.supports_datetime_with_precision? |
| 5 | + create_table :datetime_defaults, force: true do |t| |
| 6 | + t.datetime :modified_datetime, precision: nil, default: -> { "CURRENT_TIMESTAMP" } |
| 7 | + t.datetime :precise_datetime, default: -> { "CURRENT_TIMESTAMP(6)" } |
| 8 | + t.datetime :updated_datetime, default: -> { "CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)" } |
| 9 | + end |
| 10 | + |
| 11 | + create_table :timestamp_defaults, force: true do |t| |
| 12 | + t.timestamp :nullable_timestamp |
| 13 | + t.timestamp :modified_timestamp, precision: nil, default: -> { "CURRENT_TIMESTAMP" } |
| 14 | + t.timestamp :precise_timestamp, precision: 6, default: -> { "CURRENT_TIMESTAMP(6)" } |
| 15 | + t.timestamp :updated_timestamp, precision: 6, default: -> { "CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)" } |
| 16 | + end |
| 17 | + end |
| 18 | + |
| 19 | + create_table :defaults, force: true do |t| |
| 20 | + t.date :fixed_date, default: "2004-01-01" |
| 21 | + t.datetime :fixed_time, default: "2004-01-01 00:00:00" |
| 22 | + t.column :char1, "char(1)", default: "Y" |
| 23 | + t.string :char2, limit: 50, default: "a varchar field" |
| 24 | + if ActiveRecord::TestCase.supports_default_expression? |
| 25 | + t.binary :uuid, limit: 36, default: -> { "(uuid())" } |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + create_table :binary_fields, force: true do |t| |
| 30 | + t.binary :var_binary, limit: 255 |
| 31 | + t.binary :var_binary_large, limit: 4095 |
| 32 | + |
| 33 | + t.tinyblob :tiny_blob |
| 34 | + t.blob :normal_blob |
| 35 | + t.mediumblob :medium_blob |
| 36 | + t.longblob :long_blob |
| 37 | + t.tinytext :tiny_text |
| 38 | + t.text :normal_text |
| 39 | + t.mediumtext :medium_text |
| 40 | + t.longtext :long_text |
| 41 | + |
| 42 | + t.binary :tiny_blob_2, size: :tiny |
| 43 | + t.binary :medium_blob_2, size: :medium |
| 44 | + t.binary :long_blob_2, size: :long |
| 45 | + t.text :tiny_text_2, size: :tiny |
| 46 | + t.text :medium_text_2, size: :medium |
| 47 | + t.text :long_text_2, size: :long |
| 48 | + |
| 49 | + t.index :var_binary |
| 50 | + end |
| 51 | + |
| 52 | + create_table :key_tests, force: true, options: "CHARSET=utf8 ENGINE=MyISAM" do |t| |
| 53 | + t.string :awesome |
| 54 | + t.string :pizza |
| 55 | + t.string :snacks |
| 56 | + t.index :awesome, type: :fulltext, name: "index_key_tests_on_awesome" |
| 57 | + t.index :pizza, using: :btree, name: "index_key_tests_on_pizza" |
| 58 | + t.index :snacks, name: "index_key_tests_on_snack" |
| 59 | + end |
| 60 | + |
| 61 | + create_table :collation_tests, id: false, force: true do |t| |
| 62 | + t.string :string_cs_column, limit: 1, collation: "utf8mb4_bin" |
| 63 | + t.string :string_ci_column, limit: 1, collation: "utf8mb4_general_ci" |
| 64 | + t.binary :binary_column, limit: 1 |
| 65 | + end |
| 66 | + |
| 67 | + execute "DROP PROCEDURE IF EXISTS ten" |
| 68 | + |
| 69 | + execute <<~SQL |
| 70 | + CREATE PROCEDURE ten() SQL SECURITY INVOKER |
| 71 | + BEGIN |
| 72 | + SELECT 10; |
| 73 | + END |
| 74 | + SQL |
| 75 | + |
| 76 | + execute "DROP PROCEDURE IF EXISTS topics" |
| 77 | + |
| 78 | + execute <<~SQL |
| 79 | + CREATE PROCEDURE topics(IN num INT) SQL SECURITY INVOKER |
| 80 | + BEGIN |
| 81 | + SELECT * FROM topics LIMIT num; |
| 82 | + END |
| 83 | + SQL |
| 84 | +end |
0 commit comments