mirror of
https://github.com/github/rails.git
synced 2026-01-29 08:18:03 -05:00
Merge branch 'master' of git@github.com:rails/rails
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1 +1,7 @@
|
||||
debug.log
|
||||
debug.log
|
||||
activeresource/doc
|
||||
activerecord/doc
|
||||
actionpack/doc
|
||||
actionmailer/doc
|
||||
activesupport/doc
|
||||
railties/doc
|
||||
|
||||
@@ -73,21 +73,36 @@ module ActionMailer #:nodoc:
|
||||
# <%= truncate(note.body, 25) %>
|
||||
#
|
||||
#
|
||||
# = Generating URLs for mailer views
|
||||
# = Generating URLs
|
||||
#
|
||||
# URLs can be generated in mailer views using <tt>url_for</tt> or named routes.
|
||||
# Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request,
|
||||
# so you'll need to provide all of the details needed to generate a URL.
|
||||
#
|
||||
# If your view includes URLs from the application, you need to use url_for in the mailing method instead of the view.
|
||||
# Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request. That's
|
||||
# why you need to jump this little hoop and supply all the details needed for the URL. Example:
|
||||
# When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
|
||||
#
|
||||
# <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
|
||||
#
|
||||
# def signup_notification(recipient)
|
||||
# recipients recipient.email_address_with_name
|
||||
# from "system@example.com"
|
||||
# subject "New account information"
|
||||
# body :account => recipient,
|
||||
# :home_page => url_for(:host => "example.com", :controller => "welcome", :action => "greeting")
|
||||
# end
|
||||
# When using named routes you only need to supply the <tt>:host</tt>:
|
||||
#
|
||||
# <%= users_url(:host => "example.com") %>
|
||||
#
|
||||
# You can now access @home_page in the template and get http://example.com/welcome/greeting.
|
||||
# You will want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't make sense to
|
||||
# generate relative URLs in email messages.
|
||||
#
|
||||
# It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option in
|
||||
# the <tt>ActionMailer::Base.default_url_options</tt> hash as follows:
|
||||
#
|
||||
# ActionMailer::Base.default_url_options[:host] = "example.com"
|
||||
#
|
||||
# This can also be set as a configuration option in <tt>environment.rb</tt>:
|
||||
#
|
||||
# config.action_mailer.default_url_options = { :host => "example.com" }
|
||||
#
|
||||
# If you do decide to set a default <tt>:host</tt> for your mailers you will want to use the
|
||||
# <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are generated because
|
||||
# the <tt>url_for</tt> view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't
|
||||
# explicitly provided.
|
||||
#
|
||||
# = Sending mail
|
||||
#
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
*SVN*
|
||||
|
||||
* Reduce number of instance variables being copied from controller to view. [Pratik]
|
||||
|
||||
* select_datetime and select_time default to Time.zone.now when config.time_zone is set [Geoff Buesing]
|
||||
|
||||
* datetime_select defaults to Time.zone.now when config.time_zone is set [Geoff Buesing]
|
||||
|
||||
* Remove ActionController::Base#view_controller_internals flag. [Pratik]
|
||||
|
||||
* Add conditional options to caches_page method. [Paul Horsfall]
|
||||
|
||||
* Move missing template logic to ActionView. [Pratik]
|
||||
|
||||
* Introduce ActionView::InlineTemplate class. [Pratik]
|
||||
|
||||
* Automatically parse posted JSON content for Mime::JSON requests. [rick]
|
||||
|
||||
POST /posts
|
||||
|
||||
@@ -16,9 +16,6 @@ module ActionController #:nodoc:
|
||||
class SessionRestoreError < ActionControllerError #:nodoc:
|
||||
end
|
||||
|
||||
class MissingTemplate < ActionControllerError #:nodoc:
|
||||
end
|
||||
|
||||
class RenderError < ActionControllerError #:nodoc:
|
||||
end
|
||||
|
||||
@@ -256,16 +253,12 @@ module ActionController #:nodoc:
|
||||
DEFAULT_RENDER_STATUS_CODE = "200 OK"
|
||||
|
||||
include StatusCodes
|
||||
|
||||
# Determines whether the view has access to controller internals @request, @response, @session, and @template.
|
||||
# By default, it does.
|
||||
@@view_controller_internals = true
|
||||
cattr_accessor :view_controller_internals
|
||||
|
||||
# Protected instance variable cache
|
||||
@@protected_variables_cache = nil
|
||||
cattr_accessor :protected_variables_cache
|
||||
|
||||
|
||||
# Controller specific instance variables which will not be accessible inside views.
|
||||
@@protected_view_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
|
||||
@action_name @before_filter_chain_aborted @action_cache_path @_session @_cookies @_headers @_params
|
||||
@_flash @_response)
|
||||
|
||||
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
|
||||
# and images to a dedicated asset server away from the main web server. Example:
|
||||
# ActionController::Base.asset_host = "http://assets.example.com"
|
||||
@@ -330,9 +323,6 @@ module ActionController #:nodoc:
|
||||
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
|
||||
cattr_accessor :logger
|
||||
|
||||
# Turn on +ignore_missing_templates+ if you want to unit test actions without making the associated templates.
|
||||
cattr_accessor :ignore_missing_templates
|
||||
|
||||
# Controls the resource action separator
|
||||
@@resource_action_separator = "/"
|
||||
cattr_accessor :resource_action_separator
|
||||
@@ -870,7 +860,7 @@ module ActionController #:nodoc:
|
||||
|
||||
elsif inline = options[:inline]
|
||||
add_variables_to_assigns
|
||||
tmpl = ActionView::Template.new(@template, options[:inline], false, options[:locals], true, options[:type])
|
||||
tmpl = ActionView::InlineTemplate.new(@template, options[:inline], options[:locals], options[:type])
|
||||
render_for_text(@template.render_template(tmpl), options[:status])
|
||||
|
||||
elsif action_name = options[:action]
|
||||
@@ -1105,7 +1095,6 @@ module ActionController #:nodoc:
|
||||
private
|
||||
def render_for_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc:
|
||||
add_variables_to_assigns
|
||||
assert_existence_of_template_file(template_path) if use_full_path
|
||||
logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger
|
||||
render_for_text(@template.render_file(template_path, use_full_path, locals), status)
|
||||
end
|
||||
@@ -1201,7 +1190,6 @@ module ActionController #:nodoc:
|
||||
def add_variables_to_assigns
|
||||
unless @variables_added
|
||||
add_instance_variables_to_assigns
|
||||
add_class_variables_to_assigns if view_controller_internals
|
||||
@variables_added = true
|
||||
end
|
||||
end
|
||||
@@ -1215,30 +1203,11 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
def add_instance_variables_to_assigns
|
||||
@@protected_variables_cache ||= Set.new(protected_instance_variables)
|
||||
instance_variable_names.each do |var|
|
||||
next if @@protected_variables_cache.include?(var)
|
||||
(instance_variable_names - @@protected_view_variables).each do |var|
|
||||
@assigns[var[1..-1]] = instance_variable_get(var)
|
||||
end
|
||||
end
|
||||
|
||||
def add_class_variables_to_assigns
|
||||
%w(view_paths logger ignore_missing_templates).each do |cvar|
|
||||
@assigns[cvar] = self.send(cvar)
|
||||
end
|
||||
end
|
||||
|
||||
def protected_instance_variables
|
||||
if view_controller_internals
|
||||
%w(@assigns @performed_redirect @performed_render)
|
||||
else
|
||||
%w(@assigns @performed_redirect @performed_render
|
||||
@_request @request @_response @response @_params @params
|
||||
@_session @session @_cookies @cookies
|
||||
@template @request_origin @parent_controller)
|
||||
end
|
||||
end
|
||||
|
||||
def request_origin
|
||||
# this *needs* to be cached!
|
||||
# otherwise you'd get different results if calling it more than once
|
||||
@@ -1267,15 +1236,6 @@ module ActionController #:nodoc:
|
||||
@@exempt_from_layout.any? { |ext| name_with_extension =~ ext }
|
||||
end
|
||||
|
||||
def assert_existence_of_template_file(template_name)
|
||||
unless template_exists?(template_name) || ignore_missing_templates
|
||||
full_template_path = template_name.include?('.') ? template_name : "#{template_name}.#{@template.template_format}.erb"
|
||||
display_paths = view_paths.join(':')
|
||||
template_type = (template_name =~ /layouts/i) ? 'layout' : 'template'
|
||||
raise(MissingTemplate, "Missing #{template_type} #{full_template_path} in view path #{display_paths}")
|
||||
end
|
||||
end
|
||||
|
||||
def default_template_name(action_name = self.action_name)
|
||||
if action_name
|
||||
action_name = action_name.to_s
|
||||
|
||||
@@ -41,7 +41,6 @@ module ActionController #:nodoc:
|
||||
base.extend(ClassMethods)
|
||||
base.class_eval do
|
||||
attr_accessor :rendered_action_cache, :action_cache_path
|
||||
alias_method_chain :protected_instance_variables, :action_caching
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,10 +54,6 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
protected
|
||||
def protected_instance_variables_with_action_caching
|
||||
protected_instance_variables_without_action_caching + %w(@action_cache_path)
|
||||
end
|
||||
|
||||
def expire_action(options = {})
|
||||
return unless cache_configured?
|
||||
|
||||
|
||||
@@ -78,10 +78,18 @@ module ActionController #:nodoc:
|
||||
|
||||
# Caches the +actions+ using the page-caching approach that'll store the cache in a path within the page_cache_directory that
|
||||
# matches the triggering url.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# # cache the index action
|
||||
# caches_page :index
|
||||
#
|
||||
# # cache the index action except for JSON requests
|
||||
# caches_page :index, :if => Proc.new { |c| !c.request.format.json? }
|
||||
def caches_page(*actions)
|
||||
return unless perform_caching
|
||||
actions = actions.map(&:to_s)
|
||||
after_filter { |c| c.cache_page if actions.include?(c.action_name) }
|
||||
options = actions.extract_options!
|
||||
after_filter({:only => actions}.merge(options)) { |c| c.cache_page }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,6 +5,30 @@ module ActionController
|
||||
@@guard = Mutex.new
|
||||
|
||||
class << self
|
||||
def define_dispatcher_callbacks(cache_classes)
|
||||
unless cache_classes
|
||||
# Development mode callbacks
|
||||
before_dispatch :reload_application
|
||||
after_dispatch :cleanup_application
|
||||
end
|
||||
|
||||
# Common callbacks
|
||||
to_prepare :load_application_controller do
|
||||
begin
|
||||
require_dependency 'application' unless defined?(::ApplicationController)
|
||||
rescue LoadError => error
|
||||
raise unless error.message =~ /application\.rb/
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(ActiveRecord)
|
||||
before_dispatch { ActiveRecord::Base.verify_active_connections! }
|
||||
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
|
||||
end
|
||||
|
||||
after_dispatch :flush_logger if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:flush)
|
||||
end
|
||||
|
||||
# Backward-compatible class method takes CGI-specific args. Deprecated
|
||||
# in favor of Dispatcher.new(output, request, response).dispatch.
|
||||
def dispatch(cgi = nil, session_options = CgiRequest::DEFAULT_SESSION_OPTIONS, output = $stdout)
|
||||
@@ -22,7 +46,7 @@ module ActionController
|
||||
def to_prepare(identifier = nil, &block)
|
||||
@prepare_dispatch_callbacks ||= ActiveSupport::Callbacks::CallbackChain.new
|
||||
callback = ActiveSupport::Callbacks::Callback.new(:prepare_dispatch, block, :identifier => identifier)
|
||||
@prepare_dispatch_callbacks.replace_or_append_callback(callback)
|
||||
@prepare_dispatch_callbacks | callback
|
||||
end
|
||||
|
||||
# If the block raises, send status code as a last-ditch response.
|
||||
@@ -69,23 +93,9 @@ module ActionController
|
||||
cattr_accessor :error_file_path
|
||||
self.error_file_path = Rails.public_path if defined?(Rails.public_path)
|
||||
|
||||
cattr_accessor :unprepared
|
||||
self.unprepared = true
|
||||
|
||||
include ActiveSupport::Callbacks
|
||||
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
|
||||
|
||||
before_dispatch :reload_application
|
||||
before_dispatch :prepare_application
|
||||
after_dispatch :flush_logger
|
||||
after_dispatch :cleanup_application
|
||||
|
||||
if defined? ActiveRecord
|
||||
to_prepare :activerecord_instantiate_observers do
|
||||
ActiveRecord::Base.instantiate_observers
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(output, request = nil, response = nil)
|
||||
@output, @request, @response = output, request, response
|
||||
end
|
||||
@@ -114,40 +124,23 @@ module ActionController
|
||||
end
|
||||
|
||||
def reload_application
|
||||
if Dependencies.load?
|
||||
Routing::Routes.reload
|
||||
self.unprepared = true
|
||||
end
|
||||
end
|
||||
# Run prepare callbacks before every request in development mode
|
||||
run_callbacks :prepare_dispatch
|
||||
|
||||
def prepare_application(force = false)
|
||||
begin
|
||||
require_dependency 'application' unless defined?(::ApplicationController)
|
||||
rescue LoadError => error
|
||||
raise unless error.message =~ /application\.rb/
|
||||
end
|
||||
|
||||
ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord)
|
||||
|
||||
if unprepared || force
|
||||
run_callbacks :prepare_dispatch
|
||||
ActionView::TemplateFinder.reload! unless ActionView::Base.cache_template_loading
|
||||
self.unprepared = false
|
||||
end
|
||||
Routing::Routes.reload
|
||||
ActionView::TemplateFinder.reload! unless ActionView::Base.cache_template_loading
|
||||
end
|
||||
|
||||
# Cleanup the application by clearing out loaded classes so they can
|
||||
# be reloaded on the next request without restarting the server.
|
||||
def cleanup_application(force = false)
|
||||
if Dependencies.load? || force
|
||||
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
|
||||
Dependencies.clear
|
||||
ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
|
||||
end
|
||||
def cleanup_application
|
||||
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
|
||||
Dependencies.clear
|
||||
ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
|
||||
end
|
||||
|
||||
def flush_logger
|
||||
RAILS_DEFAULT_LOGGER.flush if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:flush)
|
||||
RAILS_DEFAULT_LOGGER.flush
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -265,7 +265,7 @@ module ActionController #:nodoc:
|
||||
def skip_filter_in_chain(*filters, &test)
|
||||
filters, conditions = extract_options(filters)
|
||||
filters.each do |filter|
|
||||
if callback = find_callback(filter) then delete(callback) end
|
||||
if callback = find(filter) then delete(callback) end
|
||||
end if conditions.empty?
|
||||
update_filter_in_chain(filters, :skip => conditions, &test)
|
||||
end
|
||||
@@ -302,7 +302,7 @@ module ActionController #:nodoc:
|
||||
def find_or_create_filter(filter, filter_type, options = {})
|
||||
update_filter_in_chain([filter], options)
|
||||
|
||||
if found_filter = find_callback(filter) { |f| f.type == filter_type }
|
||||
if found_filter = find(filter) { |f| f.type == filter_type }
|
||||
found_filter
|
||||
else
|
||||
filter_kind = case
|
||||
@@ -326,7 +326,7 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
def update_filter_in_chain(filters, options, &test)
|
||||
filters.map! { |f| block_given? ? find_callback(f, &test) : find_callback(f) }
|
||||
filters.map! { |f| block_given? ? find(f, &test) : find(f) }
|
||||
filters.compact!
|
||||
|
||||
map! do |filter|
|
||||
|
||||
@@ -244,9 +244,7 @@ module ActionController #:nodoc:
|
||||
def render_with_a_layout(options = nil, extra_options = {}, &block) #:nodoc:
|
||||
template_with_options = options.is_a?(Hash)
|
||||
|
||||
if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options))
|
||||
assert_existence_of_template_file(layout)
|
||||
|
||||
if (layout = pick_layout(template_with_options, options)) && apply_layout?(template_with_options, options)
|
||||
options = options.merge :layout => false if template_with_options
|
||||
logger.info("Rendering template within #{layout}") if logger
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ module ActionController #:nodoc:
|
||||
|
||||
DEFAULT_RESCUE_TEMPLATE = 'diagnostics'
|
||||
DEFAULT_RESCUE_TEMPLATES = {
|
||||
'ActionController::MissingTemplate' => 'missing_template',
|
||||
'ActionView::MissingTemplate' => 'missing_template',
|
||||
'ActionController::RoutingError' => 'routing_error',
|
||||
'ActionController::UnknownAction' => 'unknown_action',
|
||||
'ActionView::TemplateError' => 'template_error'
|
||||
|
||||
@@ -527,7 +527,7 @@ module ActionController
|
||||
action_path = action
|
||||
if resource.options[:path_names]
|
||||
action_path = resource.options[:path_names][action]
|
||||
action_path ||= Base.resources_path_names[action]
|
||||
action_path ||= Base.resources_path_names[action] || action
|
||||
end
|
||||
|
||||
map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action_path}", action_options)
|
||||
|
||||
@@ -30,6 +30,7 @@ require 'action_view/template_handlers/rjs'
|
||||
require 'action_view/template_finder'
|
||||
require 'action_view/template'
|
||||
require 'action_view/partial_template'
|
||||
require 'action_view/inline_template'
|
||||
|
||||
require 'action_view/base'
|
||||
require 'action_view/partials'
|
||||
@@ -37,6 +38,8 @@ require 'action_view/template_error'
|
||||
|
||||
ActionView::Base.class_eval do
|
||||
include ActionView::Partials
|
||||
end
|
||||
|
||||
ActionView::Base.load_helpers
|
||||
ActionView::Base.helper_modules.each do |helper_module|
|
||||
include helper_module
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
module ActionView #:nodoc:
|
||||
class ActionViewError < StandardError #:nodoc:
|
||||
end
|
||||
|
||||
class MissingTemplate < ActionViewError #:nodoc:
|
||||
end
|
||||
|
||||
# Action View templates can be written in three ways. If the template file has a +.erb+ (or +.rhtml+) extension then it uses a mixture of ERb
|
||||
# (included in Ruby) and HTML. If the template file has a +.builder+ (or +.rxml+) extension then Jim Weirich's Builder::XmlMarkup library is used.
|
||||
@@ -153,9 +156,6 @@ module ActionView #:nodoc:
|
||||
attr_reader :finder
|
||||
attr_accessor :base_path, :assigns, :template_extension, :first_render
|
||||
attr_accessor :controller
|
||||
|
||||
attr_reader :logger, :response, :headers
|
||||
attr_internal :cookies, :flash, :headers, :params, :request, :response, :session
|
||||
|
||||
attr_writer :template_format
|
||||
attr_accessor :current_render_extension
|
||||
@@ -182,7 +182,10 @@ module ActionView #:nodoc:
|
||||
@@erb_variable = '_erbout'
|
||||
cattr_accessor :erb_variable
|
||||
|
||||
delegate :request_forgery_protection_token, :to => :controller
|
||||
attr_internal :request
|
||||
|
||||
delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
|
||||
:flash, :logger, :to => :controller
|
||||
|
||||
module CompiledTemplates #:nodoc:
|
||||
# holds compiled template code
|
||||
@@ -202,22 +205,23 @@ module ActionView #:nodoc:
|
||||
class ObjectWrapper < Struct.new(:value) #:nodoc:
|
||||
end
|
||||
|
||||
def self.load_helpers #:nodoc:
|
||||
Dir.entries("#{File.dirname(__FILE__)}/helpers").sort.each do |file|
|
||||
def self.helper_modules #:nodoc:
|
||||
helpers = []
|
||||
Dir.entries(File.expand_path("#{File.dirname(__FILE__)}/helpers")).sort.each do |file|
|
||||
next unless file =~ /^([a-z][a-z_]*_helper).rb$/
|
||||
require "action_view/helpers/#{$1}"
|
||||
helper_module_name = $1.camelize
|
||||
if Helpers.const_defined?(helper_module_name)
|
||||
include Helpers.const_get(helper_module_name)
|
||||
helpers << Helpers.const_get(helper_module_name)
|
||||
end
|
||||
end
|
||||
return helpers
|
||||
end
|
||||
|
||||
def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc:
|
||||
@assigns = assigns_for_first_render
|
||||
@assigns_added = nil
|
||||
@controller = controller
|
||||
@logger = controller && controller.logger
|
||||
@finder = TemplateFinder.new(self, view_paths)
|
||||
end
|
||||
|
||||
@@ -279,7 +283,7 @@ If you are rendering a subtemplate, you must now use controller-like partial syn
|
||||
elsif options[:partial]
|
||||
render_partial(options[:partial], ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals])
|
||||
elsif options[:inline]
|
||||
template = Template.new(self, options[:inline], false, options[:locals], true, options[:type])
|
||||
template = InlineTemplate.new(self, options[:inline], options[:locals], options[:type])
|
||||
render_template(template)
|
||||
end
|
||||
end
|
||||
@@ -320,7 +324,7 @@ If you are rendering a subtemplate, you must now use controller-like partial syn
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
def wrap_content_for_layout(content)
|
||||
original_content_for_layout = @content_for_layout
|
||||
@content_for_layout = content
|
||||
|
||||
@@ -250,7 +250,7 @@ module ActionView
|
||||
# # prefixed with 'payday' rather than 'date'
|
||||
# select_datetime(my_date_time, :prefix => 'payday')
|
||||
#
|
||||
def select_datetime(datetime = Time.now, options = {}, html_options = {})
|
||||
def select_datetime(datetime = Time.current, options = {}, html_options = {})
|
||||
separator = options[:datetime_separator] || ''
|
||||
select_date(datetime, options, html_options) + separator + select_time(datetime, options, html_options)
|
||||
end
|
||||
@@ -321,7 +321,7 @@ module ActionView
|
||||
# # separated by ':' and includes an input for seconds
|
||||
# select_time(my_time, :time_separator => ':', :include_seconds => true)
|
||||
#
|
||||
def select_time(datetime = Time.now, options = {}, html_options = {})
|
||||
def select_time(datetime = Time.current, options = {}, html_options = {})
|
||||
separator = options[:time_separator] || ''
|
||||
select_hour(datetime, options, html_options) + separator + select_minute(datetime, options, html_options) + (options[:include_seconds] ? separator + select_second(datetime, options, html_options) : '')
|
||||
end
|
||||
@@ -675,7 +675,7 @@ module ActionView
|
||||
def default_time_from_options(default)
|
||||
case default
|
||||
when nil
|
||||
Time.now
|
||||
Time.current
|
||||
when Date, Time
|
||||
default
|
||||
else
|
||||
|
||||
20
actionpack/lib/action_view/inline_template.rb
Normal file
20
actionpack/lib/action_view/inline_template.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module ActionView #:nodoc:
|
||||
class InlineTemplate < Template #:nodoc:
|
||||
|
||||
def initialize(view, source, locals = {}, type = nil)
|
||||
@view = view
|
||||
@finder = @view.finder
|
||||
|
||||
@source = source
|
||||
@extension = type
|
||||
@locals = locals || {}
|
||||
|
||||
@handler = self.class.handler_class_for_extension(@extension).new(@view)
|
||||
end
|
||||
|
||||
def method_key
|
||||
@source
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -2,22 +2,18 @@ module ActionView #:nodoc:
|
||||
class Template #:nodoc:
|
||||
|
||||
attr_accessor :locals
|
||||
attr_reader :handler, :path, :source, :extension, :filename, :path_without_extension, :method
|
||||
attr_reader :handler, :path, :extension, :filename, :path_without_extension, :method
|
||||
|
||||
def initialize(view, path_or_source, use_full_path, locals = {}, inline = false, inline_type = nil)
|
||||
def initialize(view, path, use_full_path, locals = {})
|
||||
@view = view
|
||||
@finder = @view.finder
|
||||
|
||||
unless inline
|
||||
# Clear the forward slash at the beginning if exists
|
||||
@path = use_full_path ? path_or_source.sub(/^\//, '') : path_or_source
|
||||
@view.first_render ||= @path
|
||||
@source = nil # Don't read the source until we know that it is required
|
||||
set_extension_and_file_name(use_full_path)
|
||||
else
|
||||
@source = path_or_source
|
||||
@extension = inline_type
|
||||
end
|
||||
# Clear the forward slash at the beginning if exists
|
||||
@path = use_full_path ? path.sub(/^\//, '') : path
|
||||
@view.first_render ||= @path
|
||||
@source = nil # Don't read the source until we know that it is required
|
||||
set_extension_and_file_name(use_full_path)
|
||||
|
||||
@locals = locals || {}
|
||||
@handler = self.class.handler_class_for_extension(@extension).new(@view)
|
||||
end
|
||||
@@ -32,7 +28,7 @@ module ActionView #:nodoc:
|
||||
end
|
||||
|
||||
def method_key
|
||||
@method_key ||= (@filename || @source)
|
||||
@filename
|
||||
end
|
||||
|
||||
def base_path_for_exception
|
||||
@@ -58,9 +54,8 @@ module ActionView #:nodoc:
|
||||
@filename = @finder.pick_template(@path_without_extension, @extension)
|
||||
else
|
||||
@extension = @finder.pick_template_extension(@path).to_s
|
||||
unless @extension
|
||||
raise ActionViewError, "No template found for #{@path} in #{@finder.view_paths.inspect}"
|
||||
end
|
||||
raise_missing_template_exception unless @extension
|
||||
|
||||
@filename = @finder.pick_template(@path, @extension)
|
||||
@extension = @extension.gsub(/^.+\./, '') # strip off any formats
|
||||
end
|
||||
@@ -68,9 +63,14 @@ module ActionView #:nodoc:
|
||||
@filename = @path
|
||||
end
|
||||
|
||||
if @filename.blank?
|
||||
raise ActionViewError, "Couldn't find template file for #{@path} in #{@finder.view_paths.inspect}"
|
||||
end
|
||||
raise_missing_template_exception if @filename.blank?
|
||||
end
|
||||
|
||||
def raise_missing_template_exception
|
||||
full_template_path = @path.include?('.') ? @path : "#{@path}.#{@view.template_format}.erb"
|
||||
display_paths = @finder.view_paths.join(':')
|
||||
template_type = (@path =~ /layouts/i) ? 'layout' : 'template'
|
||||
raise(MissingTemplate, "Missing #{template_type} #{full_template_path} in view path #{display_paths}")
|
||||
end
|
||||
|
||||
# Template Handlers
|
||||
|
||||
64
actionpack/lib/action_view/test_case.rb
Normal file
64
actionpack/lib/action_view/test_case.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
require 'active_support/test_case'
|
||||
|
||||
module ActionView
|
||||
class NonInferrableHelperError < ActionViewError
|
||||
def initialize(name)
|
||||
super "Unable to determine the helper to test from #{name}. " +
|
||||
"You'll need to specify it using tests YourHelper in your " +
|
||||
"test case definition"
|
||||
end
|
||||
end
|
||||
|
||||
class TestCase < ActiveSupport::TestCase
|
||||
class_inheritable_accessor :helper_class
|
||||
@@helper_class = nil
|
||||
|
||||
class << self
|
||||
def tests(helper_class)
|
||||
self.helper_class = helper_class
|
||||
end
|
||||
|
||||
def helper_class
|
||||
if current_helper_class = read_inheritable_attribute(:helper_class)
|
||||
current_helper_class
|
||||
else
|
||||
self.helper_class = determine_default_helper_class(name)
|
||||
end
|
||||
end
|
||||
|
||||
def determine_default_helper_class(name)
|
||||
name.sub(/Test$/, '').constantize
|
||||
rescue NameError
|
||||
raise NonInferrableHelperError.new(name)
|
||||
end
|
||||
end
|
||||
|
||||
ActionView::Base.helper_modules.each do |helper_module|
|
||||
include helper_module
|
||||
end
|
||||
include ActionController::PolymorphicRoutes
|
||||
include ActionController::RecordIdentifier
|
||||
|
||||
setup :setup_with_helper_class
|
||||
|
||||
def setup_with_helper_class
|
||||
self.class.send(:include, helper_class)
|
||||
end
|
||||
|
||||
class TestController < ActionController::Base
|
||||
attr_accessor :request, :response
|
||||
|
||||
def initialize
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def method_missing(selector, *args)
|
||||
controller = TestController.new
|
||||
return controller.send!(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -8,6 +8,7 @@ require 'test/unit'
|
||||
require 'action_controller'
|
||||
require 'action_controller/cgi_ext'
|
||||
require 'action_controller/test_process'
|
||||
require 'action_view/test_case'
|
||||
|
||||
begin
|
||||
require 'ruby-debug'
|
||||
@@ -19,7 +20,6 @@ end
|
||||
ActiveSupport::Deprecation.debug = true
|
||||
|
||||
ActionController::Base.logger = nil
|
||||
ActionController::Base.ignore_missing_templates = false
|
||||
ActionController::Routing::Routes.reload rescue nil
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ ActionController::Base.page_cache_directory = FILE_STORE_PATH
|
||||
ActionController::Base.cache_store = :file_store, FILE_STORE_PATH
|
||||
|
||||
class PageCachingTestController < ActionController::Base
|
||||
caches_page :ok, :no_content, :found, :not_found
|
||||
caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? }
|
||||
caches_page :found, :not_found
|
||||
|
||||
def ok
|
||||
head :ok
|
||||
@@ -127,6 +128,12 @@ class PageCachingTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_page_caching_conditional_options
|
||||
@request.env['HTTP_ACCEPT'] = 'application/json'
|
||||
get :ok
|
||||
assert_page_not_cached :ok
|
||||
end
|
||||
|
||||
private
|
||||
def assert_page_cached(action, message = "#{action} should have been cached")
|
||||
|
||||
@@ -37,7 +37,7 @@ class CookieTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def rescue_action(e)
|
||||
raise unless ActionController::MissingTemplate # No templates here, and we don't care about the output
|
||||
raise unless ActionView::MissingTemplate # No templates here, and we don't care about the output
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class CustomHandlerTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_custom_render
|
||||
template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "foo")
|
||||
template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "foo")
|
||||
|
||||
result = @view.render_template(template)
|
||||
assert_equal(
|
||||
@@ -29,7 +29,7 @@ class CustomHandlerTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_custom_render2
|
||||
template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "foo2")
|
||||
template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "foo2")
|
||||
result = @view.render_template(template)
|
||||
assert_equal(
|
||||
[ "hello <%= one %>", { :one => "two" }, @view ],
|
||||
@@ -38,7 +38,7 @@ class CustomHandlerTest < Test::Unit::TestCase
|
||||
|
||||
def test_unhandled_extension
|
||||
# uses the ERb handler by default if the extension isn't recognized
|
||||
template = ActionView::Template.new(@view, "hello <%= one %>", false, { :one => "two" }, true, "bar")
|
||||
template = ActionView::InlineTemplate.new(@view, "hello <%= one %>", { :one => "two" }, "bar")
|
||||
result = @view.render_template(template)
|
||||
assert_equal "hello two", result
|
||||
end
|
||||
|
||||
@@ -11,7 +11,13 @@ class DispatcherTest < Test::Unit::TestCase
|
||||
@output = StringIO.new
|
||||
ENV['REQUEST_METHOD'] = 'GET'
|
||||
|
||||
# Clear callbacks as they are redefined by Dispatcher#define_dispatcher_callbacks
|
||||
Dispatcher.instance_variable_set("@prepare_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Dispatcher.instance_variable_set("@before_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Dispatcher.instance_variable_set("@after_dispatch_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
|
||||
Dispatcher.stubs(:require_dependency)
|
||||
|
||||
@dispatcher = Dispatcher.new(@output)
|
||||
end
|
||||
|
||||
@@ -20,17 +26,13 @@ class DispatcherTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_clears_dependencies_after_dispatch_if_in_loading_mode
|
||||
Dependencies.stubs(:load?).returns(true)
|
||||
|
||||
ActionController::Routing::Routes.expects(:reload).once
|
||||
Dependencies.expects(:clear).once
|
||||
|
||||
dispatch
|
||||
dispatch(@output, false)
|
||||
end
|
||||
|
||||
def test_leaves_dependencies_after_dispatch_if_not_in_loading_mode
|
||||
Dependencies.stubs(:load?).returns(false)
|
||||
|
||||
ActionController::Routing::Routes.expects(:reload).never
|
||||
Dependencies.expects(:clear).never
|
||||
|
||||
@@ -51,40 +53,25 @@ class DispatcherTest < Test::Unit::TestCase
|
||||
assert_equal "Status: 400 Bad Request\r\nContent-Type: text/html\r\n\r\n<html><body><h1>400 Bad Request</h1></body></html>", @output.string
|
||||
end
|
||||
|
||||
def test_reload_application_sets_unprepared_if_loading_dependencies
|
||||
Dependencies.stubs(:load?).returns(false)
|
||||
ActionController::Routing::Routes.expects(:reload).never
|
||||
@dispatcher.unprepared = false
|
||||
@dispatcher.send!(:reload_application)
|
||||
assert !@dispatcher.unprepared
|
||||
|
||||
Dependencies.stubs(:load?).returns(true)
|
||||
ActionController::Routing::Routes.expects(:reload).once
|
||||
@dispatcher.send!(:reload_application)
|
||||
assert @dispatcher.unprepared
|
||||
end
|
||||
|
||||
def test_prepare_application_runs_callbacks_if_unprepared
|
||||
def test_prepare_callbacks
|
||||
a = b = c = nil
|
||||
Dispatcher.to_prepare { |*args| a = b = c = 1 }
|
||||
Dispatcher.to_prepare { |*args| b = c = 2 }
|
||||
Dispatcher.to_prepare { |*args| c = 3 }
|
||||
|
||||
# Skip the callbacks when already prepared.
|
||||
@dispatcher.unprepared = false
|
||||
@dispatcher.send! :prepare_application
|
||||
# Ensure to_prepare callbacks are not run when defined
|
||||
assert_nil a || b || c
|
||||
|
||||
# Perform the callbacks when unprepared.
|
||||
@dispatcher.unprepared = true
|
||||
@dispatcher.send! :prepare_application
|
||||
# Run callbacks
|
||||
@dispatcher.send :run_callbacks, :prepare_dispatch
|
||||
|
||||
assert_equal 1, a
|
||||
assert_equal 2, b
|
||||
assert_equal 3, c
|
||||
|
||||
# But when not :load, make sure they are only run once
|
||||
# Make sure they are only run once
|
||||
a = b = c = nil
|
||||
@dispatcher.send! :prepare_application
|
||||
@dispatcher.send :dispatch
|
||||
assert_nil a || b || c
|
||||
end
|
||||
|
||||
@@ -93,28 +80,20 @@ class DispatcherTest < Test::Unit::TestCase
|
||||
Dispatcher.to_prepare(:unique_id) { |*args| a = b = 1 }
|
||||
Dispatcher.to_prepare(:unique_id) { |*args| a = 2 }
|
||||
|
||||
@dispatcher.unprepared = true
|
||||
@dispatcher.send! :prepare_application
|
||||
@dispatcher.send :run_callbacks, :prepare_dispatch
|
||||
assert_equal 2, a
|
||||
assert_equal nil, b
|
||||
end
|
||||
|
||||
def test_to_prepare_only_runs_once_if_not_loading_dependencies
|
||||
Dependencies.stubs(:load?).returns(false)
|
||||
called = 0
|
||||
Dispatcher.to_prepare(:unprepared_test) { |*args| called += 1 }
|
||||
2.times { dispatch }
|
||||
assert_equal 1, called
|
||||
end
|
||||
|
||||
private
|
||||
def dispatch(output = @output)
|
||||
def dispatch(output = @output, cache_classes = true)
|
||||
controller = mock
|
||||
controller.stubs(:process).returns(controller)
|
||||
controller.stubs(:out).with(output).returns('response')
|
||||
|
||||
ActionController::Routing::Routes.stubs(:recognize).returns(controller)
|
||||
|
||||
Dispatcher.define_dispatcher_callbacks(cache_classes)
|
||||
Dispatcher.dispatch(nil, {}, output)
|
||||
end
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class FlashTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def rescue_action(e)
|
||||
raise unless ActionController::MissingTemplate === e
|
||||
raise unless ActionView::MissingTemplate === e
|
||||
end
|
||||
|
||||
# methods for test_sweep_after_halted_filter_chain
|
||||
|
||||
@@ -216,7 +216,7 @@ class LayoutExceptionRaised < Test::Unit::TestCase
|
||||
@controller = SetsNonExistentLayoutFile.new
|
||||
get :hello
|
||||
@response.template.class.module_eval { attr_accessor :exception }
|
||||
assert_equal ActionController::MissingTemplate, @response.template.exception.class
|
||||
assert_equal ActionView::MissingTemplate, @response.template.exception.class
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ class MimeControllerTest < Test::Unit::TestCase
|
||||
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
|
||||
|
||||
@request.env["HTTP_ACCEPT"] = "text/iphone"
|
||||
assert_raises(ActionController::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
|
||||
assert_raises(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -239,6 +239,14 @@ class NewRenderTestController < ActionController::Base
|
||||
render :inline => "Hello: <%= params[:name] %>"
|
||||
end
|
||||
|
||||
def accessing_request_in_template
|
||||
render :inline => "Hello: <%= request.host %>"
|
||||
end
|
||||
|
||||
def accessing_logger_in_template
|
||||
render :inline => "<%= logger.class %>"
|
||||
end
|
||||
|
||||
def accessing_params_in_template_with_layout
|
||||
render :layout => nil, :inline => "Hello: <%= params[:name] %>"
|
||||
end
|
||||
@@ -529,26 +537,13 @@ class NewRenderTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_access_to_request_in_view
|
||||
view_internals_old_value = ActionController::Base.view_controller_internals
|
||||
get :accessing_request_in_template
|
||||
assert_equal "Hello: www.nextangle.com", @response.body
|
||||
end
|
||||
|
||||
ActionController::Base.view_controller_internals = false
|
||||
ActionController::Base.protected_variables_cache = nil
|
||||
|
||||
get :hello_world
|
||||
assert !assigns.include?('_request'), '_request should not be in assigns'
|
||||
assert !assigns.include?('request'), 'request should not be in assigns'
|
||||
|
||||
ActionController::Base.view_controller_internals = true
|
||||
ActionController::Base.protected_variables_cache = nil
|
||||
|
||||
get :hello_world
|
||||
assert !assigns.include?('request'), 'request should not be in assigns'
|
||||
assert_kind_of ActionController::AbstractRequest, assigns['_request']
|
||||
assert_kind_of ActionController::AbstractRequest, @response.template.request
|
||||
|
||||
ensure
|
||||
ActionController::Base.view_controller_internals = view_internals_old_value
|
||||
ActionController::Base.protected_variables_cache = nil
|
||||
def test_access_to_logger_in_view
|
||||
get :accessing_logger_in_template
|
||||
assert_equal "Logger", @response.body
|
||||
end
|
||||
|
||||
def test_render_xml
|
||||
@@ -652,7 +647,7 @@ EOS
|
||||
end
|
||||
|
||||
def test_bad_render_to_string_still_throws_exception
|
||||
assert_raises(ActionController::MissingTemplate) { get :render_to_string_with_exception }
|
||||
assert_raises(ActionView::MissingTemplate) { get :render_to_string_with_exception }
|
||||
end
|
||||
|
||||
def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns
|
||||
@@ -787,7 +782,7 @@ EOS
|
||||
end
|
||||
|
||||
def test_render_missing_partial_template
|
||||
assert_raises(ActionView::ActionViewError) do
|
||||
assert_raises(ActionView::MissingTemplate) do
|
||||
get :missing_partial
|
||||
end
|
||||
end
|
||||
|
||||
@@ -279,7 +279,7 @@ class RescueTest < Test::Unit::TestCase
|
||||
assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates.default
|
||||
assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates[Exception.new]
|
||||
|
||||
assert_equal 'missing_template', templates[ActionController::MissingTemplate.name]
|
||||
assert_equal 'missing_template', templates[ActionView::MissingTemplate.name]
|
||||
assert_equal 'routing_error', templates[ActionController::RoutingError.name]
|
||||
assert_equal 'unknown_action', templates[ActionController::UnknownAction.name]
|
||||
assert_equal 'template_error', templates[ActionView::TemplateError.name]
|
||||
|
||||
@@ -209,6 +209,23 @@ class ResourcesTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_member_when_override_paths_for_default_restful_actions_with
|
||||
[:put, :post].each do |method|
|
||||
with_restful_routing :messages, :member => { :mark => method }, :path_names => {:new => 'nuevo'} do
|
||||
mark_options = {:action => 'mark', :id => '1', :controller => "messages"}
|
||||
mark_path = "/messages/1/mark"
|
||||
|
||||
assert_restful_routes_for :messages, :path_names => {:new => 'nuevo'} do |options|
|
||||
assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method)
|
||||
end
|
||||
|
||||
assert_restful_named_routes_for :messages, :path_names => {:new => 'nuevo'} do |options|
|
||||
assert_named_route mark_path, :mark_message_path, mark_options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_with_two_member_actions_with_same_method
|
||||
[:put, :post].each do |method|
|
||||
with_restful_routing :messages, :member => { :mark => method, :unmark => method } do
|
||||
@@ -674,11 +691,18 @@ class ResourcesTest < Test::Unit::TestCase
|
||||
options[:options] ||= {}
|
||||
options[:options][:controller] = options[:controller] || controller_name.to_s
|
||||
|
||||
new_action = "new"
|
||||
edit_action = "edit"
|
||||
if options[:path_names]
|
||||
new_action = options[:path_names][:new] || "new"
|
||||
edit_action = options[:path_names][:edit] || "edit"
|
||||
end
|
||||
|
||||
collection_path = "/#{options[:path_prefix]}#{options[:as] || controller_name}"
|
||||
member_path = "#{collection_path}/1"
|
||||
new_path = "#{collection_path}/new"
|
||||
edit_member_path = "#{member_path}/edit"
|
||||
formatted_edit_member_path = "#{member_path}/edit.xml"
|
||||
new_path = "#{collection_path}/#{new_action}"
|
||||
edit_member_path = "#{member_path}/#{edit_action}"
|
||||
formatted_edit_member_path = "#{member_path}/#{edit_action}.xml"
|
||||
|
||||
with_options(options[:options]) do |controller|
|
||||
controller.assert_routing collection_path, :action => 'index'
|
||||
@@ -730,15 +754,22 @@ class ResourcesTest < Test::Unit::TestCase
|
||||
full_prefix = "/#{options[:path_prefix]}#{options[:as] || controller_name}"
|
||||
name_prefix = options[:name_prefix]
|
||||
|
||||
new_action = "new"
|
||||
edit_action = "edit"
|
||||
if options[:path_names]
|
||||
new_action = options[:path_names][:new] || "new"
|
||||
edit_action = options[:path_names][:edit] || "edit"
|
||||
end
|
||||
|
||||
assert_named_route "#{full_prefix}", "#{name_prefix}#{controller_name}_path", options[:options]
|
||||
assert_named_route "#{full_prefix}.xml", "formatted_#{name_prefix}#{controller_name}_path", options[:options].merge( :format => 'xml')
|
||||
assert_named_route "#{full_prefix}/1", "#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
|
||||
assert_named_route "#{full_prefix}/1.xml", "formatted_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
|
||||
|
||||
assert_named_route "#{full_prefix}/new", "new_#{name_prefix}#{singular_name}_path", options[:options]
|
||||
assert_named_route "#{full_prefix}/new.xml", "formatted_new_#{name_prefix}#{singular_name}_path", options[:options].merge( :format => 'xml')
|
||||
assert_named_route "#{full_prefix}/1/edit", "edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
|
||||
assert_named_route "#{full_prefix}/1/edit.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
|
||||
assert_named_route "#{full_prefix}/#{new_action}", "new_#{name_prefix}#{singular_name}_path", options[:options]
|
||||
assert_named_route "#{full_prefix}/#{new_action}.xml", "formatted_new_#{name_prefix}#{singular_name}_path", options[:options].merge( :format => 'xml')
|
||||
assert_named_route "#{full_prefix}/1/#{edit_action}", "edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1')
|
||||
assert_named_route "#{full_prefix}/1/#{edit_action}.xml", "formatted_edit_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')
|
||||
|
||||
yield options[:options] if block_given?
|
||||
end
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class ActiveRecordHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::ActiveRecordHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
class ActiveRecordHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::ActiveRecordHelper
|
||||
|
||||
silence_warnings do
|
||||
Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class AssetTagHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::AssetTagHelper
|
||||
class AssetTagHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::AssetTagHelper
|
||||
|
||||
def setup
|
||||
silence_warnings do
|
||||
@@ -445,10 +443,8 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class AssetTagHelperNonVhostTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::AssetTagHelper
|
||||
class AssetTagHelperNonVhostTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::AssetTagHelper
|
||||
|
||||
def setup
|
||||
@controller = Class.new do
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'abstract_unit'
|
||||
require 'action_view/helpers/benchmark_helper'
|
||||
|
||||
class BenchmarkHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::BenchmarkHelper
|
||||
class BenchmarkHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::BenchmarkHelper
|
||||
|
||||
class MockLogger
|
||||
attr_reader :logged
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class DateHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::DateHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
class DateHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::DateHelper
|
||||
|
||||
silence_warnings do
|
||||
Post = Struct.new("Post", :id, :written_on, :updated_at)
|
||||
@@ -934,6 +933,24 @@ class DateHelperTest < Test::Unit::TestCase
|
||||
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector')
|
||||
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {:include_seconds => false}, :class => 'selector')
|
||||
end
|
||||
|
||||
uses_mocha 'TestDatetimeAndTimeSelectUseTimeCurrentAsDefault' do
|
||||
def test_select_datetime_uses_time_current_as_default
|
||||
time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0)
|
||||
Time.expects(:current).returns time
|
||||
expects(:select_date).with(time, anything, anything).returns('')
|
||||
expects(:select_time).with(time, anything, anything).returns('')
|
||||
select_datetime
|
||||
end
|
||||
|
||||
def test_select_time_uses_time_current_as_default
|
||||
time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0)
|
||||
Time.expects(:current).returns time
|
||||
expects(:select_hour).with(time, anything, anything).returns('')
|
||||
expects(:select_minute).with(time, anything, anything).returns('')
|
||||
select_time
|
||||
end
|
||||
end
|
||||
|
||||
def test_date_select
|
||||
@post = Post.new
|
||||
@@ -1220,6 +1237,42 @@ class DateHelperTest < Test::Unit::TestCase
|
||||
|
||||
assert_dom_equal expected, datetime_select("post", "updated_at")
|
||||
end
|
||||
|
||||
uses_mocha 'TestDatetimeSelectDefaultsToTimeZoneNowWhenConfigTimeZoneIsSet' do
|
||||
def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set
|
||||
time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0)
|
||||
time_zone = mock()
|
||||
time_zone.expects(:now).returns time
|
||||
Time.zone_default = time_zone
|
||||
@post = Post.new
|
||||
|
||||
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
||||
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
||||
expected << "</select>\n"
|
||||
|
||||
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
||||
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
||||
expected << "</select>\n"
|
||||
|
||||
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
||||
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
||||
expected << "</select>\n"
|
||||
|
||||
expected << " — "
|
||||
|
||||
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
||||
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
||||
expected << "</select>\n"
|
||||
expected << " : "
|
||||
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
||||
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
||||
expected << "</select>\n"
|
||||
|
||||
assert_dom_equal expected, datetime_select("post", "updated_at")
|
||||
ensure
|
||||
Time.zone_default = nil
|
||||
end
|
||||
end
|
||||
|
||||
def test_datetime_select_within_fields_for
|
||||
@post = Post.new
|
||||
|
||||
@@ -30,15 +30,8 @@ end
|
||||
class Comment::Nested < Comment; end
|
||||
|
||||
|
||||
class FormHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::ActiveRecordHelper
|
||||
include ActionView::Helpers::RecordIdentificationHelper
|
||||
include ActionController::PolymorphicRoutes
|
||||
class FormHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::FormHelper
|
||||
|
||||
def setup
|
||||
@post = Post.new
|
||||
|
||||
@@ -22,9 +22,8 @@ end
|
||||
|
||||
ActionView::Helpers::FormOptionsHelper::TimeZone = MockTimeZone
|
||||
|
||||
class FormOptionsHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
class FormOptionsHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::FormOptionsHelper
|
||||
|
||||
silence_warnings do
|
||||
Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin)
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class FormTagHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
class FormTagHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::FormTagHelper
|
||||
|
||||
def setup
|
||||
@controller = Class.new do
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class JavaScriptHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::JavaScriptHelper
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
class JavaScriptHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::JavaScriptHelper
|
||||
|
||||
def test_define_javascript_functions
|
||||
# check if prototype.js is included first
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class NumberHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::NumberHelper
|
||||
class NumberHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::NumberHelper
|
||||
|
||||
def test_number_to_phone
|
||||
assert_equal("800-555-1212", number_to_phone(8005551212))
|
||||
|
||||
@@ -24,24 +24,11 @@ end
|
||||
class Author::Nested < Author; end
|
||||
|
||||
|
||||
module BaseTest
|
||||
def self.included(base)
|
||||
base.send :attr_accessor, :template_format
|
||||
end
|
||||
class PrototypeHelperBaseTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::PrototypeHelper
|
||||
|
||||
attr_accessor :template_format
|
||||
|
||||
include ActionView::Helpers::JavaScriptHelper
|
||||
include ActionView::Helpers::PrototypeHelper
|
||||
include ActionView::Helpers::ScriptaculousHelper
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
include ActionView::Helpers::RecordIdentificationHelper
|
||||
include ActionController::PolymorphicRoutes
|
||||
|
||||
def setup
|
||||
@template = nil
|
||||
@controller = Class.new do
|
||||
@@ -59,25 +46,22 @@ module BaseTest
|
||||
end.new
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def request_forgery_protection_token
|
||||
nil
|
||||
end
|
||||
|
||||
def protect_against_forgery?
|
||||
false
|
||||
end
|
||||
|
||||
def create_generator
|
||||
block = Proc.new { |*args| yield *args if block_given? }
|
||||
JavaScriptGenerator.new self, &block
|
||||
end
|
||||
protected
|
||||
def request_forgery_protection_token
|
||||
nil
|
||||
end
|
||||
|
||||
def protect_against_forgery?
|
||||
false
|
||||
end
|
||||
|
||||
def create_generator
|
||||
block = Proc.new { |*args| yield *args if block_given? }
|
||||
JavaScriptGenerator.new self, &block
|
||||
end
|
||||
end
|
||||
|
||||
class PrototypeHelperTest < Test::Unit::TestCase
|
||||
include BaseTest
|
||||
|
||||
class PrototypeHelperTest < PrototypeHelperBaseTest
|
||||
def setup
|
||||
@record = @author = Author.new
|
||||
@article = Article.new
|
||||
@@ -294,9 +278,7 @@ class PrototypeHelperTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class JavaScriptGeneratorTest < Test::Unit::TestCase
|
||||
include BaseTest
|
||||
|
||||
class JavaScriptGeneratorTest < PrototypeHelperBaseTest
|
||||
def setup
|
||||
super
|
||||
@generator = create_generator
|
||||
|
||||
@@ -9,14 +9,9 @@ class Post
|
||||
end
|
||||
end
|
||||
|
||||
class RecordTagHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::RecordTagHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
include ActionView::Helpers::RecordIdentificationHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
|
||||
class RecordTagHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::RecordTagHelper
|
||||
|
||||
def setup
|
||||
@post = Post.new
|
||||
end
|
||||
|
||||
@@ -3,9 +3,8 @@ require 'testing_sandbox'
|
||||
|
||||
# The exhaustive tests are in test/controller/html/sanitizer_test.rb.
|
||||
# This tests the that the helpers hook up correctly to the sanitizer classes.
|
||||
class SanitizeHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
class SanitizeHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::SanitizeHelper
|
||||
include TestingSandbox
|
||||
|
||||
def test_strip_links
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class ScriptaculousHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::JavaScriptHelper
|
||||
include ActionView::Helpers::PrototypeHelper
|
||||
include ActionView::Helpers::ScriptaculousHelper
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
|
||||
class ScriptaculousHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::ScriptaculousHelper
|
||||
|
||||
def setup
|
||||
@controller = Class.new do
|
||||
def url_for(options)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
class TagHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::CaptureHelper
|
||||
class TagHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::TagHelper
|
||||
|
||||
def test_tag
|
||||
assert_equal "<br />", tag("br")
|
||||
|
||||
@@ -82,7 +82,7 @@ class TemplateObjectTest < Test::Unit::TestCase
|
||||
|
||||
def test_xml
|
||||
@view.template_format = :xml
|
||||
assert_raise ActionView::ActionViewError do
|
||||
assert_raise ActionView::MissingTemplate do
|
||||
ActionView::PartialTemplate.new(@view, @path, nil)
|
||||
end
|
||||
end
|
||||
|
||||
56
actionpack/test/template/test_test.rb
Normal file
56
actionpack/test/template/test_test.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
require 'abstract_unit'
|
||||
|
||||
module PeopleHelper
|
||||
def title(text)
|
||||
content_tag(:h1, text)
|
||||
end
|
||||
|
||||
def homepage_path
|
||||
people_path
|
||||
end
|
||||
|
||||
def homepage_url
|
||||
people_url
|
||||
end
|
||||
|
||||
def link_to_person(person)
|
||||
link_to person.name, person
|
||||
end
|
||||
end
|
||||
|
||||
class PeopleHelperTest < ActionView::TestCase
|
||||
def setup
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
map.people 'people', :controller => 'people', :action => 'index'
|
||||
map.connect ':controller/:action/:id'
|
||||
end
|
||||
end
|
||||
|
||||
def test_title
|
||||
assert_equal "<h1>Ruby on Rails</h1>", title("Ruby on Rails")
|
||||
end
|
||||
|
||||
def test_homepage_path
|
||||
assert_equal "/people", homepage_path
|
||||
end
|
||||
|
||||
def test_homepage_url
|
||||
assert_equal "http://test.host/people", homepage_url
|
||||
end
|
||||
|
||||
uses_mocha "link_to_person" do
|
||||
def test_link_to_person
|
||||
person = mock(:name => "David")
|
||||
expects(:mocha_mock_path).with(person).returns("/people/1")
|
||||
assert_equal '<a href="/people/1">David</a>', link_to_person(person)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class CrazyHelperTest < ActionView::TestCase
|
||||
tests PeopleHelper
|
||||
|
||||
def test_helper_class_can_be_set_manually_not_just_inferred
|
||||
assert_equal PeopleHelper, self.class.helper_class
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,8 @@
|
||||
require 'abstract_unit'
|
||||
require 'testing_sandbox'
|
||||
|
||||
class TextHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
class TextHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::TextHelper
|
||||
include TestingSandbox
|
||||
|
||||
def setup
|
||||
|
||||
@@ -2,10 +2,8 @@ require 'abstract_unit'
|
||||
|
||||
RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env)
|
||||
|
||||
class UrlHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::AssetTagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
class UrlHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::UrlHelper
|
||||
|
||||
def setup
|
||||
@controller = Class.new do
|
||||
@@ -293,7 +291,7 @@ class UrlHelperTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class UrlHelperWithControllerTest < Test::Unit::TestCase
|
||||
class UrlHelperWithControllerTest < ActionView::TestCase
|
||||
class UrlHelperController < ActionController::Base
|
||||
self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
|
||||
|
||||
@@ -310,7 +308,7 @@ class UrlHelperWithControllerTest < Test::Unit::TestCase
|
||||
def rescue_action(e) raise e end
|
||||
end
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
tests ActionView::Helpers::UrlHelper
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@@ -348,7 +346,7 @@ class UrlHelperWithControllerTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
|
||||
class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
|
||||
class TasksController < ActionController::Base
|
||||
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
|
||||
|
||||
@@ -372,7 +370,7 @@ class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
tests ActionView::Helpers::UrlHelper
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@@ -440,7 +438,7 @@ class Session
|
||||
end
|
||||
end
|
||||
|
||||
class PolymorphicControllerTest < Test::Unit::TestCase
|
||||
class PolymorphicControllerTest < ActionView::TestCase
|
||||
class WorkshopsController < ActionController::Base
|
||||
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
|
||||
|
||||
@@ -479,7 +477,7 @@ class PolymorphicControllerTest < Test::Unit::TestCase
|
||||
def rescue_action(e) raise e end
|
||||
end
|
||||
|
||||
include ActionView::Helpers::UrlHelper
|
||||
tests ActionView::Helpers::UrlHelper
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
|
||||
@@ -3,24 +3,7 @@ module ActiveModel
|
||||
def self.included(base) # :nodoc:
|
||||
base.extend(ClassMethods)
|
||||
base.send!(:include, ActiveSupport::Callbacks)
|
||||
|
||||
%w( validate validate_on_create validate_on_update ).each do |validation_method|
|
||||
base.class_eval <<-"end_eval"
|
||||
def self.#{validation_method}(*methods, &block)
|
||||
methods = CallbackChain.build(:#{validation_method}, *methods, &block)
|
||||
self.#{validation_method}_callback_chain.replace(#{validation_method}_callback_chain | methods)
|
||||
end
|
||||
|
||||
def self.#{validation_method}_callback_chain
|
||||
if chain = read_inheritable_attribute(:#{validation_method})
|
||||
return chain
|
||||
else
|
||||
write_inheritable_attribute(:#{validation_method}, CallbackChain.new)
|
||||
return #{validation_method}_callback_chain
|
||||
end
|
||||
end
|
||||
end_eval
|
||||
end
|
||||
base.define_callbacks :validate, :validate_on_create, :validate_on_update
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
@@ -19,6 +19,8 @@ RELEASE_NAME = "REL #{PKG_VERSION}"
|
||||
RUBY_FORGE_PROJECT = "activerecord"
|
||||
RUBY_FORGE_USER = "webster132"
|
||||
|
||||
MYSQL_DB_USER = 'rails'
|
||||
|
||||
PKG_FILES = FileList[
|
||||
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile"
|
||||
].exclude(/\bCVS\b|~$/)
|
||||
@@ -46,16 +48,14 @@ end
|
||||
namespace :mysql do
|
||||
desc 'Build the MySQL test databases'
|
||||
task :build_databases do
|
||||
%x( mysqladmin create activerecord_unittest )
|
||||
%x( mysqladmin create activerecord_unittest2 )
|
||||
%x( mysql -e "grant all on activerecord_unittest.* to rails@localhost" )
|
||||
%x( mysql -e "grant all on activerecord_unittest2.* to rails@localhost" )
|
||||
%x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest )
|
||||
%x( mysqladmin --user=#{MYSQL_DB_USER} create activerecord_unittest2 )
|
||||
end
|
||||
|
||||
desc 'Drop the MySQL test databases'
|
||||
task :drop_databases do
|
||||
%x( mysqladmin -f drop activerecord_unittest )
|
||||
%x( mysqladmin -f drop activerecord_unittest2 )
|
||||
%x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest )
|
||||
%x( mysqladmin --user=#{MYSQL_DB_USER} -f drop activerecord_unittest2 )
|
||||
end
|
||||
|
||||
desc 'Rebuild the MySQL test databases'
|
||||
|
||||
@@ -214,6 +214,7 @@ module ActiveRecord
|
||||
|
||||
def include?(record)
|
||||
return false unless record.is_a?(@reflection.klass)
|
||||
load_target if @reflection.options[:finder_sql] && !loaded?
|
||||
return @target.include?(record) if loaded?
|
||||
exists?(record)
|
||||
end
|
||||
|
||||
@@ -35,10 +35,10 @@ module ActiveRecord
|
||||
columns = @owner.connection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns")
|
||||
|
||||
attributes = columns.inject({}) do |attrs, column|
|
||||
case column.name
|
||||
when @reflection.primary_key_name
|
||||
case column.name.to_s
|
||||
when @reflection.primary_key_name.to_s
|
||||
attrs[column.name] = @owner.quoted_id
|
||||
when @reflection.association_foreign_key
|
||||
when @reflection.association_foreign_key.to_s
|
||||
attrs[column.name] = record.quoted_id
|
||||
else
|
||||
if record.has_attribute?(column.name)
|
||||
|
||||
@@ -178,7 +178,7 @@ module ActiveRecord
|
||||
sql = "SELECT COUNT(*) AS #{aggregate_alias}" if use_workaround
|
||||
|
||||
sql << ", #{options[:group_field]} AS #{options[:group_alias]}" if options[:group]
|
||||
sql << " FROM (SELECT DISTINCT #{column_name}" if use_workaround
|
||||
sql << " FROM (SELECT #{distinct}#{column_name}" if use_workaround
|
||||
sql << " FROM #{connection.quote_table_name(table_name)} "
|
||||
if merged_includes.any?
|
||||
join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, options[:joins])
|
||||
|
||||
@@ -617,7 +617,7 @@ module ActiveRecord
|
||||
quoted_sequence = quote_column_name(sequence)
|
||||
|
||||
select_value <<-end_sql, 'Reset sequence'
|
||||
SELECT setval('#{sequence}', (SELECT COALESCE(MAX(#{pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)
|
||||
SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)
|
||||
end_sql
|
||||
else
|
||||
@logger.warn "#{table} has primary key #{pk} with no default sequence" if @logger
|
||||
|
||||
@@ -257,7 +257,7 @@ module ActiveRecord
|
||||
record = {}
|
||||
row.each_key do |key|
|
||||
if key.is_a?(String)
|
||||
record[key.sub(/^\w+\./, '')] = row[key]
|
||||
record[key.sub(/^"?\w+"?\./, '')] = row[key]
|
||||
end
|
||||
end
|
||||
record
|
||||
|
||||
@@ -281,24 +281,7 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
base.send :include, ActiveSupport::Callbacks
|
||||
|
||||
VALIDATIONS.each do |validation_method|
|
||||
base.class_eval <<-"end_eval"
|
||||
def self.#{validation_method}(*methods, &block)
|
||||
methods = CallbackChain.build(:#{validation_method}, *methods, &block)
|
||||
self.#{validation_method}_callback_chain.replace(#{validation_method}_callback_chain | methods)
|
||||
end
|
||||
|
||||
def self.#{validation_method}_callback_chain
|
||||
if chain = read_inheritable_attribute(:#{validation_method})
|
||||
return chain
|
||||
else
|
||||
write_inheritable_attribute(:#{validation_method}, CallbackChain.new)
|
||||
return #{validation_method}_callback_chain
|
||||
end
|
||||
end
|
||||
end_eval
|
||||
end
|
||||
base.define_callbacks *VALIDATIONS
|
||||
end
|
||||
|
||||
# All of the following validations are defined in the class scope of the model that you're interested in validating.
|
||||
@@ -404,7 +387,7 @@ module ActiveRecord
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should
|
||||
# not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
def validates_confirmation_of(*attr_names)
|
||||
configuration = { :message => ActiveRecord::Errors.default_error_messages[:confirmation], :on => :save }
|
||||
configuration.update(attr_names.extract_options!)
|
||||
@@ -438,7 +421,7 @@ module ActiveRecord
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should
|
||||
# not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
def validates_acceptance_of(*attr_names)
|
||||
configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1" }
|
||||
configuration.update(attr_names.extract_options!)
|
||||
@@ -520,7 +503,7 @@ module ActiveRecord
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# * <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should
|
||||
# not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
# method, proc or string should return or evaluate to a true or false value.
|
||||
def validates_length_of(*attrs)
|
||||
# Merge given options with defaults.
|
||||
options = {
|
||||
@@ -597,7 +580,7 @@ module ActiveRecord
|
||||
# attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself.
|
||||
#
|
||||
# Because this check is performed outside the database there is still a chance that duplicate values
|
||||
# will be inserted in two parallel transactions. To guarantee against this you should create a
|
||||
# will be inserted in two parallel transactions. To guarantee against this you should create a
|
||||
# unique index on the field. See +add_index+ for more information.
|
||||
#
|
||||
# Configuration options:
|
||||
|
||||
@@ -4,65 +4,21 @@ require "cases/helper"
|
||||
class AAACreateTablesTest < ActiveRecord::TestCase
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
def test_drop_and_create_main_tables
|
||||
recreate ActiveRecord::Base unless use_migrations?
|
||||
assert true
|
||||
end
|
||||
|
||||
def test_load_schema
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
eval(File.read(SCHEMA_ROOT + "/schema.rb"))
|
||||
else
|
||||
recreate ActiveRecord::Base, '3'
|
||||
eval(File.read(SCHEMA_ROOT + "/schema.rb"))
|
||||
if File.exists?(adapter_specific_schema_file)
|
||||
eval(File.read(adapter_specific_schema_file))
|
||||
end
|
||||
assert true
|
||||
end
|
||||
|
||||
def test_drop_and_create_courses_table
|
||||
if Course.connection.supports_migrations?
|
||||
eval(File.read(SCHEMA_ROOT + "/schema2.rb"))
|
||||
end
|
||||
recreate Course, '2' unless use_migrations_for_courses?
|
||||
eval(File.read(SCHEMA_ROOT + "/schema2.rb"))
|
||||
assert true
|
||||
end
|
||||
|
||||
private
|
||||
def use_migrations?
|
||||
unittest_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + ".sql"
|
||||
not File.exist? SCHEMA_ROOT + "/#{unittest_sql_filename}"
|
||||
end
|
||||
|
||||
def use_migrations_for_courses?
|
||||
unittest2_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql"
|
||||
not File.exist? SCHEMA_ROOT + "/#{unittest2_sql_filename}"
|
||||
end
|
||||
|
||||
def recreate(base, suffix = nil)
|
||||
connection = base.connection
|
||||
adapter_name = connection.adapter_name.downcase + suffix.to_s
|
||||
execute_sql_file SCHEMA_ROOT + "/#{adapter_name}.drop.sql", connection
|
||||
execute_sql_file SCHEMA_ROOT + "/#{adapter_name}.sql", connection
|
||||
end
|
||||
|
||||
def execute_sql_file(path, connection)
|
||||
# OpenBase has a different format for sql files
|
||||
if current_adapter?(:OpenBaseAdapter) then
|
||||
File.read(path).split("go").each_with_index do |sql, i|
|
||||
begin
|
||||
# OpenBase does not support comments embedded in sql
|
||||
connection.execute(sql,"SQL statement ##{i}") unless sql.blank?
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
#$stderr.puts "warning: #{$!}"
|
||||
end
|
||||
end
|
||||
else
|
||||
File.read(path).split(';').each_with_index do |sql, i|
|
||||
begin
|
||||
connection.execute("\n\n-- statement ##{i}\n#{sql}\n") unless sql.blank?
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
#$stderr.puts "warning: #{$!}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def adapter_specific_schema_file
|
||||
SCHEMA_ROOT + '/' + ActiveRecord::Base.connection.adapter_name.downcase + '_specific_schema.rb'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,6 +50,23 @@ class DeveloperForProjectWithAfterCreateHook < ActiveRecord::Base
|
||||
:foreign_key => "developer_id"
|
||||
end
|
||||
|
||||
class ProjectWithSymbolsForKeys < ActiveRecord::Base
|
||||
set_table_name 'projects'
|
||||
has_and_belongs_to_many :developers,
|
||||
:class_name => "DeveloperWithSymbolsForKeys",
|
||||
:join_table => :developers_projects,
|
||||
:foreign_key => :project_id,
|
||||
:association_foreign_key => "developer_id"
|
||||
end
|
||||
|
||||
class DeveloperWithSymbolsForKeys < ActiveRecord::Base
|
||||
set_table_name 'developers'
|
||||
has_and_belongs_to_many :projects,
|
||||
:class_name => "ProjectWithSymbolsForKeys",
|
||||
:join_table => :developers_projects,
|
||||
:association_foreign_key => :project_id,
|
||||
:foreign_key => "developer_id"
|
||||
end
|
||||
|
||||
class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
|
||||
fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects,
|
||||
@@ -650,4 +667,16 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
|
||||
def test_has_many_through_polymorphic_has_manys_works
|
||||
assert_equal [10, 20].to_set, pirates(:redbeard).treasure_estimates.map(&:price).to_set
|
||||
end
|
||||
|
||||
def test_symbols_as_keys
|
||||
developer = DeveloperWithSymbolsForKeys.new(:name => 'David')
|
||||
project = ProjectWithSymbolsForKeys.new(:name => 'Rails Testing')
|
||||
project.developers << developer
|
||||
project.save!
|
||||
|
||||
assert_equal 1, project.developers.size
|
||||
assert_equal 1, developer.projects.size
|
||||
assert_equal developer, project.developers.find(:first)
|
||||
assert_equal project, developer.projects.find(:first)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -832,6 +832,17 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
|
||||
assert ! firm.clients.loaded?
|
||||
end
|
||||
|
||||
def test_include_loads_collection_if_target_uses_finder_sql
|
||||
firm = companies(:first_firm)
|
||||
client = firm.clients_using_sql.first
|
||||
|
||||
firm.reload
|
||||
assert ! firm.clients_using_sql.loaded?
|
||||
assert firm.clients_using_sql.include?(client)
|
||||
assert firm.clients_using_sql.loaded?
|
||||
end
|
||||
|
||||
|
||||
def test_include_returns_false_for_non_matching_record_to_verify_scoping
|
||||
firm = companies(:first_firm)
|
||||
client = Client.create!(:name => 'Not Associated')
|
||||
|
||||
@@ -25,7 +25,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
|
||||
new_person = nil # so block binding catches it
|
||||
|
||||
assert_queries(0) do
|
||||
new_person = Person.new
|
||||
new_person = Person.new :first_name => 'bob'
|
||||
end
|
||||
|
||||
# Associating new records always saves them
|
||||
|
||||
@@ -41,7 +41,7 @@ class AssociationsTest < ActiveRecord::TestCase
|
||||
end
|
||||
|
||||
def test_should_construct_new_finder_sql_after_create
|
||||
person = Person.new
|
||||
person = Person.new :first_name => 'clark'
|
||||
assert_equal [], person.readers.find(:all)
|
||||
person.save!
|
||||
reader = Reader.create! :person => person, :post => Post.new(:title => "foo", :body => "bar")
|
||||
|
||||
@@ -1704,7 +1704,7 @@ class BasicsTest < ActiveRecord::TestCase
|
||||
old_class = LooseDescendant
|
||||
Object.send :remove_const, :LooseDescendant
|
||||
|
||||
descendant = old_class.create!
|
||||
descendant = old_class.create! :first_name => 'bob'
|
||||
assert_not_nil LoosePerson.find(descendant.id), "Should have found instance of LooseDescendant when finding abstract LoosePerson: #{descendant.inspect}"
|
||||
ensure
|
||||
unless Object.const_defined?(:LooseDescendant)
|
||||
|
||||
@@ -79,6 +79,7 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||
# Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word
|
||||
# OpenBase does not have named indexes. You must specify a single column name
|
||||
unless current_adapter?(:OpenBaseAdapter)
|
||||
Person.update_all "#{Person.connection.quote_column_name 'key'}=#{Person.connection.quote_column_name 'id'}" #some databases (including sqlite2 won't add a unique index if existing data non unique)
|
||||
assert_nothing_raised { Person.connection.add_index("people", ["key"], :name => "key_idx", :unique => true) }
|
||||
assert_nothing_raised { Person.connection.remove_index("people", :name => "key_idx", :unique => true) }
|
||||
end
|
||||
|
||||
@@ -58,9 +58,9 @@ class ValidationsTest < ActiveRecord::TestCase
|
||||
fixtures :topics, :developers, 'warehouse-things'
|
||||
|
||||
def setup
|
||||
Topic.write_inheritable_attribute(:validate, nil)
|
||||
Topic.write_inheritable_attribute(:validate_on_create, nil)
|
||||
Topic.write_inheritable_attribute(:validate_on_update, nil)
|
||||
Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
end
|
||||
|
||||
def test_single_field_validation
|
||||
@@ -839,16 +839,16 @@ class ValidationsTest < ActiveRecord::TestCase
|
||||
reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain')
|
||||
assert t.valid?
|
||||
end
|
||||
|
||||
|
||||
def test_validates_size_of_association_using_within
|
||||
assert_nothing_raised { Topic.validates_size_of :replies, :within => 1..2 }
|
||||
t = Topic.new('title' => 'noreplies', 'content' => 'whatever')
|
||||
assert !t.save
|
||||
assert t.errors.on(:replies)
|
||||
|
||||
|
||||
reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain')
|
||||
assert t.valid?
|
||||
|
||||
|
||||
2.times { t.replies.build('title' => 'areply', 'content' => 'whateveragain') }
|
||||
assert !t.save
|
||||
assert t.errors.on(:replies)
|
||||
@@ -1351,9 +1351,9 @@ class ValidatesNumericalityTest < ActiveRecord::TestCase
|
||||
JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"]
|
||||
|
||||
def setup
|
||||
Topic.write_inheritable_attribute(:validate, nil)
|
||||
Topic.write_inheritable_attribute(:validate_on_create, nil)
|
||||
Topic.write_inheritable_attribute(:validate_on_update, nil)
|
||||
Topic.instance_variable_set("@validate_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Topic.instance_variable_set("@validate_on_create_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
Topic.instance_variable_set("@validate_on_update_callbacks", ActiveSupport::Callbacks::CallbackChain.new)
|
||||
end
|
||||
|
||||
def test_default_validates_numericality_of
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
DROP TABLE accounts;
|
||||
DROP TABLE funny_jokes;
|
||||
DROP TABLE companies;
|
||||
DROP TABLE topics;
|
||||
DROP TABLE developers;
|
||||
DROP TABLE projects;
|
||||
DROP TABLE developers_projects;
|
||||
DROP TABLE orders;
|
||||
DROP TABLE customers;
|
||||
DROP TABLE movies;
|
||||
DROP TABLE subscribers;
|
||||
DROP TABLE booleantests;
|
||||
DROP TABLE auto_id_tests;
|
||||
DROP TABLE entrants;
|
||||
DROP TABLE colnametests;
|
||||
DROP TABLE mixins;
|
||||
DROP TABLE people;
|
||||
DROP TABLE readers;
|
||||
DROP TABLE binaries;
|
||||
DROP TABLE computers;
|
||||
DROP TABLE posts;
|
||||
DROP TABLE comments;
|
||||
DROP TABLE authors;
|
||||
DROP TABLE tasks;
|
||||
DROP TABLE categories;
|
||||
DROP TABLE categories_posts;
|
||||
DROP TABLE fk_test_has_pk;
|
||||
DROP TABLE fk_test_has_fk;
|
||||
DROP TABLE keyboards;
|
||||
DROP TABLE legacy_things;
|
||||
DROP TABLE numeric_data;
|
||||
DROP TABLE mixed_case_monkeys;
|
||||
DROP TABLE minimalistics;
|
||||
@@ -1,235 +0,0 @@
|
||||
CREATE TABLE accounts (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
firm_id INT DEFAULT NULL,
|
||||
credit_limit INT DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(50) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE companies (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
type VARCHAR(50) DEFAULT NULL,
|
||||
ruby_type VARCHAR(50) DEFAULT NULL,
|
||||
firm_id INT DEFAULT NULL,
|
||||
name VARCHAR(50) DEFAULT NULL,
|
||||
client_of INT DEFAULT NULL,
|
||||
rating INT DEFAULT 1,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE topics (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
title VARCHAR(255) DEFAULT NULL,
|
||||
author_name VARCHAR(255) DEFAULT NULL,
|
||||
author_email_address VARCHAR(255) DEFAULT NULL,
|
||||
written_on TIMESTAMP DEFAULT NULL,
|
||||
bonus_time TIME DEFAULT NULL,
|
||||
last_read DATE DEFAULT NULL,
|
||||
content VARCHAR(3000),
|
||||
approved SMALLINT DEFAULT 1,
|
||||
replies_count INT DEFAULT 0,
|
||||
parent_id INT DEFAULT NULL,
|
||||
type VARCHAR(50) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE developers (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
salary INT DEFAULT 70000,
|
||||
created_at TIMESTAMP DEFAULT NULL,
|
||||
updated_at TIMESTAMP DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE projects (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
type VARCHAR(255) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id INT NOT NULL,
|
||||
project_id INT NOT NULL,
|
||||
joined_on DATE DEFAULT NULL,
|
||||
access_level SMALLINT DEFAULT 1
|
||||
);
|
||||
|
||||
CREATE TABLE orders (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
billing_customer_id INT DEFAULT NULL,
|
||||
shipping_customer_id INT DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE customers (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
balance INT DEFAULT 0,
|
||||
address_street VARCHAR(100) DEFAULT NULL,
|
||||
address_city VARCHAR(100) DEFAULT NULL,
|
||||
address_country VARCHAR(100) DEFAULT NULL,
|
||||
gps_location VARCHAR(100) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
PRIMARY KEY (movieid)
|
||||
);
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(100) DEFAULT NULL,
|
||||
PRIMARY KEY (nick)
|
||||
);
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
value INT DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
value INT DEFAULT NULL,
|
||||
PRIMARY KEY (auto_id)
|
||||
);
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id INT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
course_id INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
references INT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
parent_id INT DEFAULT NULL,
|
||||
pos INT DEFAULT NULL,
|
||||
created_at TIMESTAMP DEFAULT NULL,
|
||||
updated_at TIMESTAMP DEFAULT NULL,
|
||||
lft INT DEFAULT NULL,
|
||||
rgt INT DEFAULT NULL,
|
||||
root_id INT DEFAULT NULL,
|
||||
type VARCHAR(40) DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE people (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
first_name VARCHAR(40) NOT NULL,
|
||||
lock_version INT DEFAULT 0,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE readers (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
post_id INT NOT NULL,
|
||||
person_id INT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
data BLOB(50000),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE computers (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
developer INT NOT NULL,
|
||||
extendedWarranty INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE posts (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
author_id INT DEFAULT NULL,
|
||||
title VARCHAR(255) DEFAULT NULL,
|
||||
type VARCHAR(255) DEFAULT NULL,
|
||||
body VARCHAR(3000) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE comments (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
post_id INT DEFAULT NULL,
|
||||
type VARCHAR(255) DEFAULT NULL,
|
||||
body VARCHAR(3000) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE authors (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
starting TIMESTAMP DEFAULT NULL,
|
||||
ending TIMESTAMP DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE categories (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(40) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id INT NOT NULL,
|
||||
post_id INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
name VARCHAR(255)
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id INT NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id INT NOT NULL PRIMARY KEY,
|
||||
fk_id INT NOT NULL,
|
||||
|
||||
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
||||
);
|
||||
|
||||
--This table has an altered lock_version column name
|
||||
CREATE TABLE legacy_things (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
||||
tps_report_number INT DEFAULT NULL,
|
||||
version INT DEFAULT 0,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id INT NOT NULL PRIMARY KEY,
|
||||
bank_balance DECIMAL(10,2),
|
||||
big_bank_balance DECIMAL(15,2),
|
||||
world_population DECIMAL(10),
|
||||
my_house_population DECIMAL(2),
|
||||
decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78
|
||||
);
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
monkeyID INT NOT NULL PRIMARY KEY,
|
||||
fleaCount INT
|
||||
);
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id INT NOT NULL PRIMARY KEY
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE courses;
|
||||
@@ -1,4 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id INT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL
|
||||
);
|
||||
@@ -1,65 +0,0 @@
|
||||
DROP TABLE accounts;
|
||||
DROP TABLE funny_jokes;
|
||||
DROP TABLE companies;
|
||||
DROP TABLE topics;
|
||||
DROP TABLE developers;
|
||||
DROP TABLE projects;
|
||||
DROP TABLE developers_projects;
|
||||
DROP TABLE orders;
|
||||
DROP TABLE customers;
|
||||
DROP TABLE movies;
|
||||
DROP TABLE subscribers;
|
||||
DROP TABLE booleantests;
|
||||
DROP TABLE auto_id_tests;
|
||||
DROP TABLE entrants;
|
||||
DROP TABLE colnametests;
|
||||
DROP TABLE mixins;
|
||||
DROP TABLE people;
|
||||
DROP TABLE readers;
|
||||
DROP TABLE binaries;
|
||||
DROP TABLE computers;
|
||||
DROP TABLE posts;
|
||||
DROP TABLE comments;
|
||||
DROP TABLE authors;
|
||||
DROP TABLE tasks;
|
||||
DROP TABLE categories;
|
||||
DROP TABLE categories_posts;
|
||||
DROP TABLE fk_test_has_fk;
|
||||
DROP TABLE fk_test_has_pk;
|
||||
DROP TABLE keyboards;
|
||||
DROP TABLE defaults;
|
||||
DROP TABLE legacy_things;
|
||||
DROP TABLE numeric_data;
|
||||
DROP TABLE mixed_case_monkeys;
|
||||
DROP TABLE minimalistics;
|
||||
|
||||
DROP DOMAIN D_BOOLEAN;
|
||||
|
||||
DROP GENERATOR accounts_seq;
|
||||
DROP GENERATOR funny_jokes_seq;
|
||||
DROP GENERATOR companies_nonstd_seq;
|
||||
DROP GENERATOR topics_seq;
|
||||
DROP GENERATOR developers_seq;
|
||||
DROP GENERATOR projects_seq;
|
||||
DROP GENERATOR orders_seq;
|
||||
DROP GENERATOR customers_seq;
|
||||
DROP GENERATOR movies_seq;
|
||||
DROP GENERATOR booleantests_seq;
|
||||
DROP GENERATOR auto_id_tests_seq;
|
||||
DROP GENERATOR entrants_seq;
|
||||
DROP GENERATOR colnametests_seq;
|
||||
DROP GENERATOR mixins_seq;
|
||||
DROP GENERATOR people_seq;
|
||||
DROP GENERATOR binaries_seq;
|
||||
DROP GENERATOR computers_seq;
|
||||
DROP GENERATOR posts_seq;
|
||||
DROP GENERATOR comments_seq;
|
||||
DROP GENERATOR authors_seq;
|
||||
DROP GENERATOR tasks_seq;
|
||||
DROP GENERATOR categories_seq;
|
||||
DROP GENERATOR keyboards_seq;
|
||||
DROP GENERATOR defaults_seq;
|
||||
DROP GENERATOR legacy_things_seq;
|
||||
DROP GENERATOR numeric_data_seq;
|
||||
DROP GENERATOR mixed_case_monkeys_seq;
|
||||
DROP GENERATOR minimalistics_seq;
|
||||
@@ -1,310 +0,0 @@
|
||||
CREATE DOMAIN D_BOOLEAN AS SMALLINT CHECK (VALUE IN (0, 1) OR VALUE IS NULL);
|
||||
|
||||
CREATE TABLE accounts (
|
||||
id BIGINT NOT NULL,
|
||||
firm_id BIGINT,
|
||||
credit_limit INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR accounts_seq;
|
||||
SET GENERATOR accounts_seq TO 10000;
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(50),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR funny_jokes_seq;
|
||||
SET GENERATOR funny_jokes_seq TO 10000;
|
||||
|
||||
CREATE TABLE companies (
|
||||
id BIGINT NOT NULL,
|
||||
"TYPE" VARCHAR(50),
|
||||
ruby_type VARCHAR(50),
|
||||
firm_id BIGINT,
|
||||
name VARCHAR(50),
|
||||
client_of INTEGER,
|
||||
rating INTEGER DEFAULT 1,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR companies_nonstd_seq;
|
||||
SET GENERATOR companies_nonstd_seq TO 10000;
|
||||
|
||||
CREATE TABLE topics (
|
||||
id BIGINT NOT NULL,
|
||||
title VARCHAR(255),
|
||||
author_name VARCHAR(255),
|
||||
author_email_address VARCHAR(255),
|
||||
written_on TIMESTAMP,
|
||||
bonus_time TIME,
|
||||
last_read DATE,
|
||||
content VARCHAR(4000),
|
||||
approved D_BOOLEAN DEFAULT 1,
|
||||
replies_count INTEGER DEFAULT 0,
|
||||
parent_id BIGINT,
|
||||
"TYPE" VARCHAR(50),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR topics_seq;
|
||||
SET GENERATOR topics_seq TO 10000;
|
||||
|
||||
CREATE TABLE developers (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(100),
|
||||
salary INTEGER DEFAULT 70000,
|
||||
created_at TIMESTAMP,
|
||||
updated_at TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR developers_seq;
|
||||
SET GENERATOR developers_seq TO 10000;
|
||||
|
||||
CREATE TABLE projects (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(100),
|
||||
"TYPE" VARCHAR(255),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR projects_seq;
|
||||
SET GENERATOR projects_seq TO 10000;
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id BIGINT NOT NULL,
|
||||
project_id BIGINT NOT NULL,
|
||||
joined_on DATE,
|
||||
access_level SMALLINT DEFAULT 1
|
||||
);
|
||||
|
||||
CREATE TABLE orders (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(100),
|
||||
billing_customer_id BIGINT,
|
||||
shipping_customer_id BIGINT,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR orders_seq;
|
||||
SET GENERATOR orders_seq TO 10000;
|
||||
|
||||
CREATE TABLE customers (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(100),
|
||||
balance INTEGER DEFAULT 0,
|
||||
address_street VARCHAR(100),
|
||||
address_city VARCHAR(100),
|
||||
address_country VARCHAR(100),
|
||||
gps_location VARCHAR(100),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR customers_seq;
|
||||
SET GENERATOR customers_seq TO 10000;
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid BIGINT NOT NULL,
|
||||
name varchar(100),
|
||||
PRIMARY KEY (movieid)
|
||||
);
|
||||
CREATE GENERATOR movies_seq;
|
||||
SET GENERATOR movies_seq TO 10000;
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(100),
|
||||
PRIMARY KEY (nick)
|
||||
);
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id BIGINT NOT NULL,
|
||||
"VALUE" D_BOOLEAN,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR booleantests_seq;
|
||||
SET GENERATOR booleantests_seq TO 10000;
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id BIGINT NOT NULL,
|
||||
"VALUE" INTEGER,
|
||||
PRIMARY KEY (auto_id)
|
||||
);
|
||||
CREATE GENERATOR auto_id_tests_seq;
|
||||
SET GENERATOR auto_id_tests_seq TO 10000;
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
course_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR entrants_seq;
|
||||
SET GENERATOR entrants_seq TO 10000;
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id BIGINT NOT NULL,
|
||||
"REFERENCES" INTEGER NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR colnametests_seq;
|
||||
SET GENERATOR colnametests_seq TO 10000;
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id BIGINT NOT NULL,
|
||||
parent_id BIGINT,
|
||||
pos INTEGER,
|
||||
created_at TIMESTAMP,
|
||||
updated_at TIMESTAMP,
|
||||
lft INTEGER,
|
||||
rgt INTEGER,
|
||||
root_id BIGINT,
|
||||
"TYPE" VARCHAR(40),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR mixins_seq;
|
||||
SET GENERATOR mixins_seq TO 10000;
|
||||
|
||||
CREATE TABLE people (
|
||||
id BIGINT NOT NULL,
|
||||
first_name VARCHAR(40),
|
||||
lock_version INTEGER DEFAULT 0 NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR people_seq;
|
||||
SET GENERATOR people_seq TO 10000;
|
||||
|
||||
CREATE TABLE readers (
|
||||
id BIGINT NOT NULL,
|
||||
post_id BIGINT NOT NULL,
|
||||
person_id BIGINT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR readers_seq;
|
||||
SET GENERATOR readers_seq TO 10000;
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id BIGINT NOT NULL,
|
||||
data BLOB,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR binaries_seq;
|
||||
SET GENERATOR binaries_seq TO 10000;
|
||||
|
||||
CREATE TABLE computers (
|
||||
id BIGINT NOT NULL,
|
||||
developer INTEGER NOT NULL,
|
||||
"extendedWarranty" INTEGER NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR computers_seq;
|
||||
SET GENERATOR computers_seq TO 10000;
|
||||
|
||||
CREATE TABLE posts (
|
||||
id BIGINT NOT NULL,
|
||||
author_id BIGINT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
"TYPE" VARCHAR(255) NOT NULL,
|
||||
body VARCHAR(3000) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR posts_seq;
|
||||
SET GENERATOR posts_seq TO 10000;
|
||||
|
||||
CREATE TABLE comments (
|
||||
id BIGINT NOT NULL,
|
||||
post_id BIGINT NOT NULL,
|
||||
"TYPE" VARCHAR(255) NOT NULL,
|
||||
body VARCHAR(3000) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR comments_seq;
|
||||
SET GENERATOR comments_seq TO 10000;
|
||||
|
||||
CREATE TABLE authors (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR authors_seq;
|
||||
SET GENERATOR authors_seq TO 10000;
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id BIGINT NOT NULL,
|
||||
"STARTING" TIMESTAMP,
|
||||
ending TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR tasks_seq;
|
||||
SET GENERATOR tasks_seq TO 10000;
|
||||
|
||||
CREATE TABLE categories (
|
||||
id BIGINT NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
"TYPE" VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR categories_seq;
|
||||
SET GENERATOR categories_seq TO 10000;
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id BIGINT NOT NULL,
|
||||
post_id BIGINT NOT NULL,
|
||||
PRIMARY KEY (category_id, post_id)
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id BIGINT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id BIGINT NOT NULL,
|
||||
fk_id BIGINT NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
||||
);
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number BIGINT NOT NULL,
|
||||
name VARCHAR(50),
|
||||
PRIMARY KEY (key_number)
|
||||
);
|
||||
CREATE GENERATOR keyboards_seq;
|
||||
SET GENERATOR keyboards_seq TO 10000;
|
||||
|
||||
CREATE TABLE defaults (
|
||||
id BIGINT NOT NULL,
|
||||
default_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE GENERATOR defaults_seq;
|
||||
SET GENERATOR defaults_seq TO 10000;
|
||||
|
||||
CREATE TABLE legacy_things (
|
||||
id BIGINT NOT NULL,
|
||||
tps_report_number INTEGER,
|
||||
version INTEGER DEFAULT 0 NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR legacy_things_seq;
|
||||
SET GENERATOR legacy_things_seq TO 10000;
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id BIGINT NOT NULL,
|
||||
bank_balance DECIMAL(10,2),
|
||||
big_bank_balance DECIMAL(15,2),
|
||||
world_population DECIMAL(10),
|
||||
my_house_population DECIMAL(2),
|
||||
decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE GENERATOR numeric_data_seq;
|
||||
SET GENERATOR numeric_data_seq TO 10000;
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
"monkeyID" BIGINT NOT NULL,
|
||||
"fleaCount" INTEGER
|
||||
);
|
||||
CREATE GENERATOR mixed_case_monkeys_seq;
|
||||
SET GENERATOR mixed_case_monkeys_seq TO 10000;
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id BIGINT NOT NULL
|
||||
);
|
||||
CREATE GENERATOR minimalistics_seq;
|
||||
SET GENERATOR minimalistics_seq TO 10000;
|
||||
@@ -1,2 +0,0 @@
|
||||
DROP TABLE courses;
|
||||
DROP GENERATOR courses_seq;
|
||||
@@ -1,6 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL
|
||||
);
|
||||
CREATE GENERATOR courses_seq;
|
||||
SET GENERATOR courses_seq TO 10000;
|
||||
@@ -1,33 +0,0 @@
|
||||
DROP TABLE accounts CASCADE;
|
||||
DROP TABLE funny_jokes CASCADE;
|
||||
DROP TABLE companies CASCADE;
|
||||
DROP TABLE topics CASCADE;
|
||||
DROP TABLE developers CASCADE;
|
||||
DROP TABLE projects CASCADE;
|
||||
DROP TABLE developers_projects CASCADE;
|
||||
DROP TABLE orders CASCADE;
|
||||
DROP TABLE customers CASCADE;
|
||||
DROP TABLE movies CASCADE;
|
||||
DROP TABLE subscribers CASCADE;
|
||||
DROP TABLE booleantests CASCADE;
|
||||
DROP TABLE auto_id_tests CASCADE;
|
||||
DROP TABLE entrants CASCADE;
|
||||
DROP TABLE colnametests CASCADE;
|
||||
DROP TABLE mixins CASCADE;
|
||||
DROP TABLE people CASCADE;
|
||||
DROP TABLE readers CASCADE;
|
||||
DROP TABLE binaries CASCADE;
|
||||
DROP TABLE computers CASCADE;
|
||||
DROP TABLE posts CASCADE;
|
||||
DROP TABLE comments CASCADE;
|
||||
DROP TABLE authors CASCADE;
|
||||
DROP TABLE tasks CASCADE;
|
||||
DROP TABLE categories CASCADE;
|
||||
DROP TABLE categories_posts CASCADE;
|
||||
DROP TABLE fk_test_has_fk CASCADE;
|
||||
DROP TABLE fk_test_has_pk CASCADE;
|
||||
DROP TABLE keyboards CASCADE;
|
||||
DROP TABLE legacy_things CASCADE;
|
||||
DROP TABLE numeric_data CASCADE;
|
||||
DROP TABLE mixed_case_monkeys CASCADE;
|
||||
DROP TABLE minimalistics CASCADE;
|
||||
@@ -1,273 +0,0 @@
|
||||
CREATE TABLE accounts (
|
||||
id integer DEFAULT unique,
|
||||
firm_id integer,
|
||||
credit_limit integer,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR accounts(id);
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id integer DEFAULT unique,
|
||||
firm_id integer default NULL,
|
||||
name character varying(50),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR funny_jokes(id);
|
||||
|
||||
CREATE TABLE companies (
|
||||
id integer DEFAULT unique,
|
||||
"type" character varying(50),
|
||||
"ruby_type" character varying(50),
|
||||
firm_id integer,
|
||||
name character varying(50),
|
||||
client_of integer,
|
||||
rating integer default 1,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR companies(id);
|
||||
|
||||
CREATE TABLE topics (
|
||||
id integer DEFAULT unique,
|
||||
title character varying(255),
|
||||
author_name character varying(255),
|
||||
author_email_address character varying(255),
|
||||
written_on timestamp,
|
||||
bonus_time time,
|
||||
last_read date,
|
||||
content varchar(65536),
|
||||
approved boolean default true,
|
||||
replies_count integer default 0,
|
||||
parent_id integer,
|
||||
"type" character varying(50),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR topics(id);
|
||||
|
||||
CREATE TABLE developers (
|
||||
id integer DEFAULT unique,
|
||||
name character varying(100),
|
||||
salary integer DEFAULT 70000,
|
||||
created_at timestamp,
|
||||
updated_at timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR developers(id);
|
||||
|
||||
CREATE TABLE projects (
|
||||
id integer DEFAULT unique,
|
||||
name character varying(100),
|
||||
type varchar(255),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR projects(id);
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id integer NOT NULL,
|
||||
project_id integer NOT NULL,
|
||||
joined_on date,
|
||||
access_level integer default 1
|
||||
);
|
||||
|
||||
CREATE TABLE orders (
|
||||
id integer DEFAULT unique,
|
||||
name character varying(100),
|
||||
billing_customer_id integer,
|
||||
shipping_customer_id integer,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR orders(id);
|
||||
|
||||
CREATE TABLE customers (
|
||||
id integer DEFAULT unique,
|
||||
name character varying(100),
|
||||
balance integer default 0,
|
||||
address_street character varying(100),
|
||||
address_city character varying(100),
|
||||
address_country character varying(100),
|
||||
gps_location character varying(100),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR customers(id);
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid integer DEFAULT unique,
|
||||
name varchar(65536),
|
||||
PRIMARY KEY (movieid)
|
||||
);
|
||||
SET UNIQUE FOR movies(movieid);
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick varchar(65536) NOT NULL,
|
||||
name varchar(65536),
|
||||
PRIMARY KEY (nick)
|
||||
);
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id integer DEFAULT unique,
|
||||
value boolean,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR booleantests(id);
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id integer DEFAULT unique,
|
||||
value integer,
|
||||
PRIMARY KEY (auto_id)
|
||||
);
|
||||
SET UNIQUE FOR auto_id_tests(auto_id);
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id integer DEFAULT unique,
|
||||
name varchar(65536),
|
||||
course_id integer,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR entrants(id);
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id integer DEFAULT unique,
|
||||
"references" integer NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR colnametests(id);
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id integer DEFAULT unique,
|
||||
parent_id integer,
|
||||
type character varying(100),
|
||||
pos integer,
|
||||
lft integer,
|
||||
rgt integer,
|
||||
root_id integer,
|
||||
created_at timestamp,
|
||||
updated_at timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR mixins(id);
|
||||
|
||||
CREATE TABLE people (
|
||||
id integer DEFAULT unique,
|
||||
first_name varchar(65536),
|
||||
lock_version integer default 0,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR people(id);
|
||||
|
||||
CREATE TABLE readers (
|
||||
id integer DEFAULT unique,
|
||||
post_id INTEGER NOT NULL,
|
||||
person_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR readers(id);
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id integer DEFAULT unique,
|
||||
data BLOB,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR binaries(id);
|
||||
|
||||
CREATE TABLE computers (
|
||||
id integer DEFAULT unique,
|
||||
developer integer NOT NULL,
|
||||
"extendedWarranty" integer NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR computers(id);
|
||||
|
||||
CREATE TABLE posts (
|
||||
id integer DEFAULT unique,
|
||||
author_id integer,
|
||||
title varchar(255),
|
||||
type varchar(255),
|
||||
body varchar(65536),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR posts(id);
|
||||
|
||||
CREATE TABLE comments (
|
||||
id integer DEFAULT unique,
|
||||
post_id integer,
|
||||
type varchar(255),
|
||||
body varchar(65536),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR comments(id);
|
||||
|
||||
CREATE TABLE authors (
|
||||
id integer DEFAULT unique,
|
||||
name varchar(255) default NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR authors(id);
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id integer DEFAULT unique,
|
||||
starting timestamp,
|
||||
ending timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR tasks(id);
|
||||
|
||||
CREATE TABLE categories (
|
||||
id integer DEFAULT unique,
|
||||
name varchar(255),
|
||||
type varchar(255),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
SET UNIQUE FOR categories(id);
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id integer NOT NULL,
|
||||
post_id integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
SET UNIQUE FOR fk_test_has_pk(id);
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
|
||||
);
|
||||
SET UNIQUE FOR fk_test_has_fk(id);
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number integer DEFAULT unique,
|
||||
"name" character varying(50),
|
||||
PRIMARY KEY (key_number)
|
||||
);
|
||||
SET UNIQUE FOR keyboards(key_number);
|
||||
|
||||
create table "legacy_things"
|
||||
(
|
||||
"id" int,
|
||||
"tps_report_number" int default NULL,
|
||||
"version" int default 0 not null,
|
||||
primary key ("id")
|
||||
);
|
||||
SET UNIQUE FOR legacy_things(id);
|
||||
|
||||
CREATE TABLE "numeric_data" (
|
||||
"id" integer NOT NULL
|
||||
"bank_balance" DECIMAL(10,2),
|
||||
"big_bank_balance" DECIMAL(15,2),
|
||||
"world_population" DECIMAL(10),
|
||||
"my_house_population" DECIMAL(2),
|
||||
"decimal_number_with_default" DECIMAL(3,2) DEFAULT 2.78,
|
||||
primary key ("id")
|
||||
);
|
||||
SET UNIQUE FOR numeric_data(id);
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
"monkeyID" integer DEFAULT unique,
|
||||
"fleaCount" integer
|
||||
);
|
||||
SET UNIQUE FOR mixed_case_monkeys("monkeyID");
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
"id" integer NOT NULL
|
||||
);
|
||||
SET UNIQUE FOR minimalistics("id");
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE courses CASCADE;
|
||||
@@ -1,4 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id integer DEFAULT unique,
|
||||
name varchar(100)
|
||||
);
|
||||
12
activerecord/test/schema/mysql_specific_schema.rb
Normal file
12
activerecord/test/schema/mysql_specific_schema.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
ActiveRecord::Schema.define do
|
||||
create_table :binary_fields, :force => true do |t|
|
||||
t.binary :tiny_blob, :limit => 255
|
||||
t.binary :normal_blob, :limit => 65535
|
||||
t.binary :medium_blob, :limit => 16777215
|
||||
t.binary :long_blob, :limit => 2147483647
|
||||
t.text :tiny_text, :limit => 255
|
||||
t.text :normal_text, :limit => 65535
|
||||
t.text :medium_text, :limit => 16777215
|
||||
t.text :long_text, :limit => 2147483647
|
||||
end
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
DROP ALL
|
||||
go
|
||||
@@ -1,318 +0,0 @@
|
||||
CREATE TABLE accounts (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
firm_id integer,
|
||||
credit_limit integer
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY accounts (id)
|
||||
go
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name char(50) DEFAULT NULL
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY funny_jokes (id)
|
||||
go
|
||||
|
||||
CREATE TABLE companies (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
type char(50),
|
||||
ruby_type char(50),
|
||||
firm_id integer,
|
||||
name char(50),
|
||||
client_of integer,
|
||||
rating integer default 1
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY companies (id)
|
||||
go
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id integer NOT NULL,
|
||||
project_id integer NOT NULL,
|
||||
joined_on date,
|
||||
access_level integer default 1
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE developers (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name char(100),
|
||||
salary integer DEFAULT 70000,
|
||||
created_at datetime,
|
||||
updated_at datetime
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY developers (id)
|
||||
go
|
||||
|
||||
CREATE TABLE projects (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name char(100),
|
||||
type char(255)
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY projects (id)
|
||||
go
|
||||
|
||||
CREATE TABLE topics (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
title char(255),
|
||||
author_name char(255),
|
||||
author_email_address char(255),
|
||||
written_on datetime,
|
||||
bonus_time time,
|
||||
last_read date,
|
||||
content char(4096),
|
||||
approved boolean default true,
|
||||
replies_count integer default 0,
|
||||
parent_id integer,
|
||||
type char(50)
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY topics (id)
|
||||
go
|
||||
|
||||
CREATE TABLE customers (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name char,
|
||||
balance integer default 0,
|
||||
address_street char,
|
||||
address_city char,
|
||||
address_country char,
|
||||
gps_location char
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY customers (id)
|
||||
go
|
||||
|
||||
CREATE TABLE orders (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name char,
|
||||
billing_customer_id integer,
|
||||
shipping_customer_id integer
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY orders (id)
|
||||
go
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
name text
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY movies (movieid)
|
||||
go
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick CHAR(100) NOT NULL DEFAULT _rowid,
|
||||
name CHAR(100)
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY subscribers (nick)
|
||||
go
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
value boolean
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY booleantests (id)
|
||||
go
|
||||
|
||||
CREATE TABLE defaults (
|
||||
id integer UNIQUE INDEX ,
|
||||
modified_date date default CURDATE(),
|
||||
modified_date_function date default NOW(),
|
||||
fixed_date date default '2004-01-01',
|
||||
modified_time timestamp default NOW(),
|
||||
modified_time_function timestamp default NOW(),
|
||||
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
||||
char1 char(1) default 'Y',
|
||||
char2 char(50) default 'a char field',
|
||||
char3 text default 'a text field',
|
||||
positive_integer integer default 1,
|
||||
negative_integer integer default -1,
|
||||
decimal_number money default 2.78
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY defaults (id)
|
||||
go
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
value integer
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY auto_id_tests (auto_id)
|
||||
go
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id integer NOT NULL UNIQUE INDEX,
|
||||
name text NOT NULL,
|
||||
course_id integer NOT NULL
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY entrants (id)
|
||||
go
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id integer UNIQUE INDEX ,
|
||||
references integer NOT NULL
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY colnametests (id)
|
||||
go
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
parent_id integer,
|
||||
type char,
|
||||
pos integer,
|
||||
lft integer,
|
||||
rgt integer,
|
||||
root_id integer,
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY mixins (id)
|
||||
go
|
||||
|
||||
CREATE TABLE people (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
first_name text,
|
||||
lock_version integer default 0
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY people (id)
|
||||
go
|
||||
|
||||
CREATE TABLE readers (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
post_id integer NOT NULL,
|
||||
person_id integer NOT NULL
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY readers (id)
|
||||
go
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
data object
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY binaries (id)
|
||||
go
|
||||
|
||||
CREATE TABLE computers (
|
||||
id integer UNIQUE INDEX ,
|
||||
developer integer NOT NULL,
|
||||
extendedWarranty integer NOT NULL
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE posts (
|
||||
id integer UNIQUE INDEX ,
|
||||
author_id integer,
|
||||
title char(255),
|
||||
type char(255),
|
||||
body text
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE comments (
|
||||
id integer UNIQUE INDEX ,
|
||||
post_id integer,
|
||||
type char(255),
|
||||
body text
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE authors (
|
||||
id integer UNIQUE INDEX ,
|
||||
name char(255) default NULL
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
|
||||
starting datetime,
|
||||
ending datetime
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY tasks (id)
|
||||
go
|
||||
|
||||
CREATE TABLE categories (
|
||||
id integer UNIQUE INDEX ,
|
||||
name char(255),
|
||||
type char(255)
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id integer NOT NULL,
|
||||
post_id integer NOT NULL
|
||||
)
|
||||
go
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id INTEGER NOT NULL DEFAULT _rowid
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY fk_test_has_pk (id)
|
||||
go
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id INTEGER NOT NULL DEFAULT _rowid,
|
||||
fk_id INTEGER NOT NULL REFERENCES fk_test_has_pk.id
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY fk_test_has_fk (id)
|
||||
go
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number integer UNIQUE INDEX DEFAULT _rowid,
|
||||
name char(50)
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY keyboards (key_number)
|
||||
go
|
||||
|
||||
CREATE TABLE legacy_things (
|
||||
id INTEGER NOT NULL DEFAULT _rowid,
|
||||
tps_report_number INTEGER default NULL,
|
||||
version integer NOT NULL default 0
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY legacy_things (id)
|
||||
go
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id INTEGER NOT NULL DEFAULT _rowid,
|
||||
bank_balance MONEY,
|
||||
big_bank_balance MONEY,
|
||||
world_population longlong,
|
||||
my_house_population longlong,
|
||||
decimal_number_with_default MONEY DEFAULT 2.78
|
||||
);
|
||||
go
|
||||
CREATE PRIMARY KEY numeric_data (id)
|
||||
go
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
monkeyID INTEGER NOT NULL DEFAULT _rowid,
|
||||
fleaCount INTEGER
|
||||
);
|
||||
go
|
||||
CREATE PRIMARY KEY mixed_case_monkeys (monkeyID)
|
||||
go
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id INTEGER NOT NULL DEFAULT _rowid
|
||||
);
|
||||
go
|
||||
CREATE PRIMARY KEY minimalistics (id)
|
||||
go
|
||||
@@ -1,2 +0,0 @@
|
||||
DROP TABLE courses
|
||||
go
|
||||
@@ -1,7 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id integer UNIQUE INDEX DEFAULT _rowid,
|
||||
name text
|
||||
)
|
||||
go
|
||||
CREATE PRIMARY KEY courses (id)
|
||||
go
|
||||
@@ -1,67 +0,0 @@
|
||||
drop table accounts;
|
||||
drop table funny_jokes;
|
||||
drop table companies;
|
||||
drop table topics;
|
||||
drop synonym subjects;
|
||||
drop table developers_projects;
|
||||
drop table computers;
|
||||
drop table developers;
|
||||
drop table projects;
|
||||
drop table customers;
|
||||
drop table orders;
|
||||
drop table movies;
|
||||
drop table subscribers;
|
||||
drop table booleantests;
|
||||
drop table auto_id_tests;
|
||||
drop table entrants;
|
||||
drop table colnametests;
|
||||
drop table mixins;
|
||||
drop table people;
|
||||
drop table readers;
|
||||
drop table binaries;
|
||||
drop table comments;
|
||||
drop table authors;
|
||||
drop table tasks;
|
||||
drop table categories_posts;
|
||||
drop table categories;
|
||||
drop table posts;
|
||||
drop table fk_test_has_pk;
|
||||
drop table fk_test_has_fk;
|
||||
drop table keyboards;
|
||||
drop table legacy_things;
|
||||
drop table numeric_data;
|
||||
drop table mixed_case_monkeys;
|
||||
drop table minimalistics;
|
||||
|
||||
drop sequence accounts_seq;
|
||||
drop sequence funny_jokes_seq;
|
||||
drop sequence companies_nonstd_seq;
|
||||
drop sequence topics_seq;
|
||||
drop sequence developers_seq;
|
||||
drop sequence projects_seq;
|
||||
drop sequence developers_projects_seq;
|
||||
drop sequence customers_seq;
|
||||
drop sequence orders_seq;
|
||||
drop sequence movies_seq;
|
||||
drop sequence subscribers_seq;
|
||||
drop sequence booleantests_seq;
|
||||
drop sequence auto_id_tests_seq;
|
||||
drop sequence entrants_seq;
|
||||
drop sequence colnametests_seq;
|
||||
drop sequence mixins_seq;
|
||||
drop sequence people_seq;
|
||||
drop sequence binaries_seq;
|
||||
drop sequence posts_seq;
|
||||
drop sequence comments_seq;
|
||||
drop sequence authors_seq;
|
||||
drop sequence tasks_seq;
|
||||
drop sequence computers_seq;
|
||||
drop sequence categories_seq;
|
||||
drop sequence categories_posts_seq;
|
||||
drop sequence fk_test_has_pk_seq;
|
||||
drop sequence fk_test_has_fk_seq;
|
||||
drop sequence keyboards_seq;
|
||||
drop sequence legacy_things_seq;
|
||||
drop sequence numeric_data_seq;
|
||||
drop sequence mixed_case_monkeys_seq;
|
||||
drop sequence minimalistics_seq;
|
||||
@@ -1,330 +0,0 @@
|
||||
create table companies (
|
||||
id integer not null,
|
||||
type varchar(50) default null,
|
||||
ruby_type varchar(50) default null,
|
||||
firm_id integer default null references companies initially deferred disable,
|
||||
name varchar(50) default null,
|
||||
client_of integer default null references companies initially deferred disable,
|
||||
companies_count integer default 0,
|
||||
rating integer default 1,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
-- non-standard sequence name used to test set_sequence_name
|
||||
--
|
||||
create sequence companies_nonstd_seq minvalue 10000;
|
||||
|
||||
create table funny_jokes (
|
||||
id integer not null,
|
||||
name varchar(50) default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence funny_jokes_seq minvalue 10000;
|
||||
|
||||
create table accounts (
|
||||
id integer not null,
|
||||
firm_id integer default null references companies initially deferred disable,
|
||||
credit_limit integer default null
|
||||
);
|
||||
create sequence accounts_seq minvalue 10000;
|
||||
|
||||
create table topics (
|
||||
id integer not null,
|
||||
title varchar(255) default null,
|
||||
author_name varchar(255) default null,
|
||||
author_email_address varchar(255) default null,
|
||||
written_on timestamp default null,
|
||||
bonus_time timestamp default null,
|
||||
last_read timestamp default null,
|
||||
content varchar(4000),
|
||||
approved number(1) default 1,
|
||||
replies_count integer default 0,
|
||||
parent_id integer references topics initially deferred disable,
|
||||
type varchar(50) default null,
|
||||
primary key (id)
|
||||
);
|
||||
-- try again for 8i
|
||||
create table topics (
|
||||
id integer not null,
|
||||
title varchar(255) default null,
|
||||
author_name varchar(255) default null,
|
||||
author_email_address varchar(255) default null,
|
||||
written_on date default null,
|
||||
bonus_time date default null,
|
||||
last_read date default null,
|
||||
content varchar(4000),
|
||||
approved number(1) default 1,
|
||||
replies_count integer default 0,
|
||||
parent_id integer references topics initially deferred disable,
|
||||
type varchar(50) default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence topics_seq minvalue 10000;
|
||||
|
||||
create synonym subjects for topics;
|
||||
|
||||
create table developers (
|
||||
id integer not null,
|
||||
name varchar(100) default null,
|
||||
salary integer default 70000,
|
||||
created_at timestamp default null,
|
||||
updated_at timestamp default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence developers_seq minvalue 10000;
|
||||
|
||||
create table projects (
|
||||
id integer not null,
|
||||
name varchar(100) default null,
|
||||
type varchar(255) default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence projects_seq minvalue 10000;
|
||||
|
||||
create table developers_projects (
|
||||
developer_id integer not null references developers initially deferred disable,
|
||||
project_id integer not null references projects initially deferred disable,
|
||||
joined_on timestamp default null,
|
||||
access_level integer default 1
|
||||
);
|
||||
-- Try again for 8i
|
||||
create table developers_projects (
|
||||
developer_id integer not null references developers initially deferred disable,
|
||||
project_id integer not null references projects initially deferred disable,
|
||||
joined_on date default null
|
||||
);
|
||||
create sequence developers_projects_seq minvalue 10000;
|
||||
|
||||
create table orders (
|
||||
id integer not null,
|
||||
name varchar(100) default null,
|
||||
billing_customer_id integer default null,
|
||||
shipping_customer_id integer default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence orders_seq minvalue 10000;
|
||||
|
||||
create table customers (
|
||||
id integer not null,
|
||||
name varchar(100) default null,
|
||||
balance integer default 0,
|
||||
address_street varchar(100) default null,
|
||||
address_city varchar(100) default null,
|
||||
address_country varchar(100) default null,
|
||||
gps_location varchar(100) default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence customers_seq minvalue 10000;
|
||||
|
||||
create table movies (
|
||||
movieid integer not null,
|
||||
name varchar(100) default null,
|
||||
primary key (movieid)
|
||||
);
|
||||
create sequence movies_seq minvalue 10000;
|
||||
|
||||
create table subscribers (
|
||||
nick varchar(100) not null,
|
||||
name varchar(100) default null,
|
||||
primary key (nick)
|
||||
);
|
||||
create sequence subscribers_seq minvalue 10000;
|
||||
|
||||
create table booleantests (
|
||||
id integer not null,
|
||||
value integer default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence booleantests_seq minvalue 10000;
|
||||
|
||||
CREATE TABLE defaults (
|
||||
id integer not null,
|
||||
modified_date date default sysdate,
|
||||
modified_date_function date default sysdate,
|
||||
fixed_date date default to_date('2004-01-01', 'YYYY-MM-DD'),
|
||||
modified_time date default sysdate,
|
||||
modified_time_function date default sysdate,
|
||||
fixed_time date default TO_DATE('2004-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
|
||||
char1 varchar2(1) default 'Y',
|
||||
char2 varchar2(50) default 'a varchar field',
|
||||
char3 clob default 'a text field',
|
||||
positive_integer integer default 1,
|
||||
negative_integer integer default -1,
|
||||
decimal_number number(3,2) default 2.78
|
||||
);
|
||||
create sequence defaults_seq minvalue 10000;
|
||||
|
||||
create table auto_id_tests (
|
||||
auto_id integer not null,
|
||||
value integer default null,
|
||||
primary key (auto_id)
|
||||
);
|
||||
create sequence auto_id_tests_seq minvalue 10000;
|
||||
|
||||
create table entrants (
|
||||
id integer not null primary key,
|
||||
name varchar(255) not null,
|
||||
course_id integer not null
|
||||
);
|
||||
create sequence entrants_seq minvalue 10000;
|
||||
|
||||
create table colnametests (
|
||||
id integer not null,
|
||||
references integer not null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence colnametests_seq minvalue 10000;
|
||||
|
||||
create table mixins (
|
||||
id integer not null,
|
||||
parent_id integer default null references mixins initially deferred disable,
|
||||
type varchar(40) default null,
|
||||
pos integer default null,
|
||||
lft integer default null,
|
||||
rgt integer default null,
|
||||
root_id integer default null,
|
||||
created_at timestamp default null,
|
||||
updated_at timestamp default null,
|
||||
primary key (id)
|
||||
);
|
||||
-- try again for 8i
|
||||
create table mixins (
|
||||
id integer not null,
|
||||
parent_id integer default null references mixins initially deferred disable,
|
||||
type varchar(40) default null,
|
||||
pos integer default null,
|
||||
lft integer default null,
|
||||
rgt integer default null,
|
||||
root_id integer default null,
|
||||
created_at date default null,
|
||||
updated_at date default null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence mixins_seq minvalue 10000;
|
||||
|
||||
create table people (
|
||||
id integer not null,
|
||||
first_name varchar(40) null,
|
||||
lock_version integer default 0,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence people_seq minvalue 10000;
|
||||
|
||||
create table readers (
|
||||
id integer not null,
|
||||
post_id integer not null,
|
||||
person_id integer not null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence readers_seq minvalue 10000;
|
||||
|
||||
create table binaries (
|
||||
id integer not null,
|
||||
data blob null,
|
||||
primary key (id)
|
||||
);
|
||||
create sequence binaries_seq minvalue 10000;
|
||||
|
||||
create table computers (
|
||||
id integer not null primary key,
|
||||
developer integer not null references developers initially deferred disable,
|
||||
"extendedWarranty" integer not null
|
||||
);
|
||||
create sequence computers_seq minvalue 10000;
|
||||
|
||||
create table posts (
|
||||
id integer not null primary key,
|
||||
author_id integer default null,
|
||||
title varchar(255) default null,
|
||||
type varchar(255) default null,
|
||||
body varchar(3000) default null
|
||||
);
|
||||
create sequence posts_seq minvalue 10000;
|
||||
|
||||
create table comments (
|
||||
id integer not null primary key,
|
||||
post_id integer default null,
|
||||
type varchar(255) default null,
|
||||
body varchar(3000) default null
|
||||
);
|
||||
create sequence comments_seq minvalue 10000;
|
||||
|
||||
create table authors (
|
||||
id integer not null primary key,
|
||||
name varchar(255) default null
|
||||
);
|
||||
create sequence authors_seq minvalue 10000;
|
||||
|
||||
create table tasks (
|
||||
id integer not null primary key,
|
||||
starting date default null,
|
||||
ending date default null
|
||||
);
|
||||
create sequence tasks_seq minvalue 10000;
|
||||
|
||||
create table categories (
|
||||
id integer not null primary key,
|
||||
name varchar(255) default null,
|
||||
type varchar(255) default null
|
||||
);
|
||||
create sequence categories_seq minvalue 10000;
|
||||
|
||||
create table categories_posts (
|
||||
category_id integer not null references categories initially deferred disable,
|
||||
post_id integer not null references posts initially deferred disable
|
||||
);
|
||||
create sequence categories_posts_seq minvalue 10000;
|
||||
|
||||
create table fk_test_has_pk (
|
||||
id integer not null primary key
|
||||
);
|
||||
create sequence fk_test_has_pk_seq minvalue 10000;
|
||||
|
||||
create table fk_test_has_fk (
|
||||
id integer not null primary key,
|
||||
fk_id integer not null references fk_test_has_fk initially deferred disable
|
||||
);
|
||||
create sequence fk_test_has_fk_seq minvalue 10000;
|
||||
|
||||
create table keyboards (
|
||||
key_number integer not null,
|
||||
name varchar(50) default null
|
||||
);
|
||||
create sequence keyboards_seq minvalue 10000;
|
||||
|
||||
create table test_oracle_defaults (
|
||||
id integer not null primary key,
|
||||
test_char char(1) default 'X' not null,
|
||||
test_string varchar2(20) default 'hello' not null,
|
||||
test_int integer default 3 not null
|
||||
);
|
||||
create sequence test_oracle_defaults_seq minvalue 10000;
|
||||
|
||||
--This table has an altered lock_version column name.
|
||||
create table legacy_things (
|
||||
id integer not null primary key,
|
||||
tps_report_number integer default null,
|
||||
version integer default 0
|
||||
);
|
||||
create sequence legacy_things_seq minvalue 10000;
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id integer NOT NULL PRIMARY KEY,
|
||||
bank_balance decimal(10,2),
|
||||
big_bank_balance decimal(15,2),
|
||||
world_population decimal(10),
|
||||
my_house_population decimal(2),
|
||||
decimal_number_with_default decimal(3,2) DEFAULT 2.78
|
||||
);
|
||||
create sequence numeric_data_seq minvalue 10000;
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
"monkeyID" INTEGER NOT NULL PRIMARY KEY,
|
||||
"fleaCount" INTEGER
|
||||
);
|
||||
create sequence mixed_case_monkeys_seq minvalue 10000;
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
create sequence minimalistics_seq minvalue 10000;
|
||||
@@ -1,2 +0,0 @@
|
||||
drop table courses;
|
||||
drop sequence courses_seq;
|
||||
@@ -1,6 +0,0 @@
|
||||
create table courses (
|
||||
id int not null primary key,
|
||||
name varchar(255) not null
|
||||
);
|
||||
|
||||
create sequence courses_seq minvalue 10000;
|
||||
@@ -1,44 +0,0 @@
|
||||
DROP TABLE accounts;
|
||||
DROP SEQUENCE accounts_id_seq;
|
||||
DROP TABLE funny_jokes;
|
||||
DROP TABLE companies;
|
||||
DROP SEQUENCE companies_nonstd_seq;
|
||||
DROP TABLE topics;
|
||||
DROP TABLE developers;
|
||||
DROP TABLE projects;
|
||||
DROP TABLE developers_projects;
|
||||
DROP TABLE customers;
|
||||
DROP TABLE orders;
|
||||
DROP TABLE movies;
|
||||
DROP TABLE subscribers;
|
||||
DROP TABLE booleantests;
|
||||
DROP TABLE auto_id_tests;
|
||||
DROP TABLE entrants;
|
||||
DROP TABLE colnametests;
|
||||
DROP TABLE mixins;
|
||||
DROP TABLE people;
|
||||
DROP TABLE readers;
|
||||
DROP TABLE binaries;
|
||||
DROP TABLE computers;
|
||||
DROP TABLE posts;
|
||||
DROP TABLE comments;
|
||||
DROP TABLE authors;
|
||||
DROP TABLE tasks;
|
||||
DROP TABLE categories;
|
||||
DROP TABLE categories_posts;
|
||||
DROP TABLE defaults;
|
||||
DROP TABLE fk_test_has_fk;
|
||||
DROP TABLE fk_test_has_pk;
|
||||
DROP TABLE geometrics;
|
||||
DROP TABLE keyboards;
|
||||
DROP TABLE legacy_things;
|
||||
DROP TABLE numeric_data;
|
||||
DROP TABLE column_data;
|
||||
DROP TABLE mixed_case_monkeys;
|
||||
DROP TABLE postgresql_arrays;
|
||||
DROP TABLE postgresql_moneys;
|
||||
DROP TABLE postgresql_numbers;
|
||||
DROP TABLE postgresql_times;
|
||||
DROP TABLE postgresql_network_addresses;
|
||||
DROP TABLE postgresql_bit_strings;
|
||||
DROP TABLE postgresql_oids;
|
||||
@@ -1,294 +0,0 @@
|
||||
CREATE SEQUENCE public.accounts_id_seq START 100;
|
||||
|
||||
CREATE TABLE accounts (
|
||||
id integer primary key DEFAULT nextval('public.accounts_id_seq'),
|
||||
firm_id integer,
|
||||
credit_limit integer
|
||||
);
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id serial,
|
||||
name character varying(50)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE companies_nonstd_seq START 101;
|
||||
|
||||
CREATE TABLE companies (
|
||||
id integer primary key DEFAULT nextval('companies_nonstd_seq'),
|
||||
"type" character varying(50),
|
||||
"ruby_type" character varying(50),
|
||||
firm_id integer,
|
||||
name character varying(50),
|
||||
client_of integer,
|
||||
rating integer default 1
|
||||
);
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id integer NOT NULL,
|
||||
project_id integer NOT NULL,
|
||||
joined_on date,
|
||||
access_level integer default 1
|
||||
);
|
||||
|
||||
CREATE TABLE developers (
|
||||
id serial primary key,
|
||||
name character varying(100),
|
||||
salary integer DEFAULT 70000,
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
);
|
||||
SELECT setval('developers_id_seq', 100);
|
||||
|
||||
CREATE TABLE projects (
|
||||
id serial primary key,
|
||||
name character varying(100),
|
||||
type varchar(255)
|
||||
);
|
||||
SELECT setval('projects_id_seq', 100);
|
||||
|
||||
CREATE TABLE topics (
|
||||
id serial primary key,
|
||||
title character varying(255),
|
||||
author_name character varying(255),
|
||||
author_email_address character varying(255),
|
||||
written_on timestamp without time zone,
|
||||
bonus_time time,
|
||||
last_read date,
|
||||
content text,
|
||||
approved boolean default true,
|
||||
replies_count integer default 0,
|
||||
parent_id integer,
|
||||
"type" character varying(50)
|
||||
);
|
||||
SELECT setval('topics_id_seq', 100);
|
||||
|
||||
CREATE TABLE customers (
|
||||
id serial primary key,
|
||||
name character varying,
|
||||
balance integer default 0,
|
||||
address_street character varying,
|
||||
address_city character varying,
|
||||
address_country character varying,
|
||||
gps_location character varying
|
||||
);
|
||||
SELECT setval('customers_id_seq', 100);
|
||||
|
||||
CREATE TABLE orders (
|
||||
id serial primary key,
|
||||
name character varying,
|
||||
billing_customer_id integer,
|
||||
shipping_customer_id integer
|
||||
);
|
||||
SELECT setval('orders_id_seq', 100);
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid serial primary key,
|
||||
name text
|
||||
);
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick text primary key NOT NULL,
|
||||
name text
|
||||
);
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id serial primary key,
|
||||
value boolean
|
||||
);
|
||||
|
||||
CREATE TABLE defaults (
|
||||
id serial primary key,
|
||||
modified_date date default CURRENT_DATE,
|
||||
modified_date_function date default now(),
|
||||
fixed_date date default '2004-01-01',
|
||||
modified_time timestamp default CURRENT_TIMESTAMP,
|
||||
modified_time_function timestamp default now(),
|
||||
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
||||
char1 char(1) default 'Y',
|
||||
char2 character varying(50) default 'a varchar field',
|
||||
char3 text default 'a text field',
|
||||
positive_integer integer default 1,
|
||||
negative_integer integer default -1,
|
||||
decimal_number decimal(3,2) default 2.78,
|
||||
multiline_default text DEFAULT '--- []
|
||||
|
||||
'::text
|
||||
);
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id serial primary key,
|
||||
value integer
|
||||
);
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id serial primary key,
|
||||
name text not null,
|
||||
course_id integer not null
|
||||
);
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id serial primary key,
|
||||
"references" integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id serial primary key,
|
||||
parent_id integer,
|
||||
type character varying,
|
||||
pos integer,
|
||||
lft integer,
|
||||
rgt integer,
|
||||
root_id integer,
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE people (
|
||||
id serial primary key,
|
||||
first_name text,
|
||||
lock_version integer default 0
|
||||
);
|
||||
|
||||
CREATE TABLE readers (
|
||||
id serial primary key,
|
||||
post_id integer NOT NULL,
|
||||
person_id integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id serial primary key,
|
||||
data bytea
|
||||
);
|
||||
|
||||
CREATE TABLE computers (
|
||||
id serial primary key,
|
||||
developer integer NOT NULL,
|
||||
"extendedWarranty" integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE posts (
|
||||
id serial primary key,
|
||||
author_id integer,
|
||||
title varchar(255),
|
||||
type varchar(255),
|
||||
body text
|
||||
);
|
||||
|
||||
CREATE TABLE comments (
|
||||
id serial primary key,
|
||||
post_id integer,
|
||||
type varchar(255),
|
||||
body text
|
||||
);
|
||||
|
||||
CREATE TABLE authors (
|
||||
id serial primary key,
|
||||
name varchar(255) default NULL
|
||||
);
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id serial primary key,
|
||||
starting timestamp,
|
||||
ending timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE categories (
|
||||
id serial primary key,
|
||||
name varchar(255),
|
||||
type varchar(255)
|
||||
);
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id integer NOT NULL,
|
||||
post_id integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
|
||||
);
|
||||
|
||||
CREATE TABLE geometrics (
|
||||
id serial primary key,
|
||||
a_point point,
|
||||
-- a_line line, (the line type is currently not implemented in postgresql)
|
||||
a_line_segment lseg,
|
||||
a_box box,
|
||||
a_path path,
|
||||
a_polygon polygon,
|
||||
a_circle circle
|
||||
);
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number serial primary key,
|
||||
"name" character varying(50)
|
||||
);
|
||||
|
||||
--Altered lock_version column name.
|
||||
CREATE TABLE legacy_things (
|
||||
id serial primary key,
|
||||
tps_report_number integer,
|
||||
version integer default 0
|
||||
);
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id serial primary key,
|
||||
bank_balance decimal(10,2),
|
||||
big_bank_balance decimal(15,2),
|
||||
world_population decimal(10),
|
||||
my_house_population decimal(2),
|
||||
decimal_number_with_default decimal(3,2) default 2.78
|
||||
);
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
"monkeyID" INTEGER PRIMARY KEY,
|
||||
"fleaCount" INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_arrays (
|
||||
id SERIAL PRIMARY KEY,
|
||||
commission_by_quarter INTEGER[],
|
||||
nicknames TEXT[]
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_moneys (
|
||||
id SERIAL PRIMARY KEY,
|
||||
wealth MONEY
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_numbers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
single REAL,
|
||||
double DOUBLE PRECISION
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_times (
|
||||
id SERIAL PRIMARY KEY,
|
||||
time_interval INTERVAL
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_network_addresses (
|
||||
id SERIAL PRIMARY KEY,
|
||||
cidr_address CIDR,
|
||||
inet_address INET,
|
||||
mac_address MACADDR
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_bit_strings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
bit_string BIT(8),
|
||||
bit_string_varying BIT VARYING(8)
|
||||
);
|
||||
|
||||
CREATE TABLE postgresql_oids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
obj_id OID
|
||||
);
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id serial primary key
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE courses;
|
||||
@@ -1,4 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
103
activerecord/test/schema/postgresql_specific_schema.rb
Normal file
103
activerecord/test/schema/postgresql_specific_schema.rb
Normal file
@@ -0,0 +1,103 @@
|
||||
ActiveRecord::Schema.define do
|
||||
|
||||
%w(postgresql_arrays postgresql_moneys postgresql_numbers postgresql_times postgresql_network_addresses postgresql_bit_strings
|
||||
postgresql_oids defaults geometrics).each do |table_name|
|
||||
drop_table table_name
|
||||
end
|
||||
|
||||
execute 'DROP SEQUENCE IF EXISTS companies_nonstd_seq CASCADE'
|
||||
execute 'CREATE SEQUENCE companies_nonstd_seq START 101 OWNED BY companies.id'
|
||||
execute "ALTER TABLE companies ALTER COLUMN id SET DEFAULT nextval('companies_nonstd_seq')"
|
||||
execute 'DROP SEQUENCE IF EXISTS companies_id_seq'
|
||||
|
||||
%w(accounts_id_seq developers_id_seq projects_id_seq topics_id_seq customers_id_seq orders_id_seq).each do |seq_name|
|
||||
execute "SELECT setval('#{seq_name}', 100)"
|
||||
end
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE defaults (
|
||||
id serial primary key,
|
||||
modified_date date default CURRENT_DATE,
|
||||
modified_date_function date default now(),
|
||||
fixed_date date default '2004-01-01',
|
||||
modified_time timestamp default CURRENT_TIMESTAMP,
|
||||
modified_time_function timestamp default now(),
|
||||
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
||||
char1 char(1) default 'Y',
|
||||
char2 character varying(50) default 'a varchar field',
|
||||
char3 text default 'a text field',
|
||||
positive_integer integer default 1,
|
||||
negative_integer integer default -1,
|
||||
decimal_number decimal(3,2) default 2.78,
|
||||
multiline_default text DEFAULT '--- []
|
||||
|
||||
'::text
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE geometrics (
|
||||
id serial primary key,
|
||||
a_point point,
|
||||
-- a_line line, (the line type is currently not implemented in postgresql)
|
||||
a_line_segment lseg,
|
||||
a_box box,
|
||||
a_path path,
|
||||
a_polygon polygon,
|
||||
a_circle circle
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_arrays (
|
||||
id SERIAL PRIMARY KEY,
|
||||
commission_by_quarter INTEGER[],
|
||||
nicknames TEXT[]
|
||||
);
|
||||
_SQL
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_moneys (
|
||||
id SERIAL PRIMARY KEY,
|
||||
wealth MONEY
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_numbers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
single REAL,
|
||||
double DOUBLE PRECISION
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_times (
|
||||
id SERIAL PRIMARY KEY,
|
||||
time_interval INTERVAL
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_network_addresses (
|
||||
id SERIAL PRIMARY KEY,
|
||||
cidr_address CIDR,
|
||||
inet_address INET,
|
||||
mac_address MACADDR
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_bit_strings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
bit_string BIT(8),
|
||||
bit_string_varying BIT VARYING(8)
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE postgresql_oids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
obj_id OID
|
||||
);
|
||||
_SQL
|
||||
end
|
||||
@@ -1,238 +1,361 @@
|
||||
|
||||
ActiveRecord::Schema.define do
|
||||
|
||||
# adapter name is checked because we are under a transition of
|
||||
# moving the sql files under activerecord/test/fixtures/db_definitions
|
||||
# to this file, schema.rb.
|
||||
if adapter_name == "MySQL"
|
||||
|
||||
# Please keep these create table statements in alphabetical order
|
||||
# unless the ordering matters. In which case, define them below
|
||||
create_table :accounts, :force => true do |t|
|
||||
t.integer :firm_id
|
||||
t.integer :credit_limit
|
||||
def except(adapter_names_to_exclude)
|
||||
unless [adapter_names_to_exclude].flatten.include?(adapter_name)
|
||||
yield
|
||||
end
|
||||
|
||||
create_table :authors, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
end
|
||||
|
||||
create_table :auto_id_tests, :force => true, :id => false do |t|
|
||||
t.primary_key :auto_id
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
create_table :binaries, :force => true do |t|
|
||||
t.binary :data
|
||||
end
|
||||
|
||||
create_table :binary_fields, :force => true do |t|
|
||||
t.binary :tiny_blob, :limit => 255
|
||||
t.binary :normal_blob, :limit => 65535
|
||||
t.binary :medium_blob, :limit => 16777215
|
||||
t.binary :long_blob, :limit => 2147483647
|
||||
t.text :tiny_text, :limit => 255
|
||||
t.text :normal_text, :limit => 65535
|
||||
t.text :medium_text, :limit => 16777215
|
||||
t.text :long_text, :limit => 2147483647
|
||||
end
|
||||
|
||||
create_table :booleantests, :force => true do |t|
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
create_table :categories, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :categories_posts, :force => true, :id => false do |t|
|
||||
t.integer :category_id, :null => false
|
||||
t.integer :post_id, :null => false
|
||||
end
|
||||
|
||||
create_table :colnametests, :force => true do |t|
|
||||
t.integer :references, :null => false
|
||||
end
|
||||
|
||||
create_table :comments, :force => true do |t|
|
||||
t.integer :post_id, :null => false
|
||||
t.text :body, :null => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :companies, :force => true do |t|
|
||||
t.string :type
|
||||
t.string :ruby_type
|
||||
t.integer :firm_id
|
||||
t.string :name
|
||||
t.integer :client_of
|
||||
t.integer :rating, :default => 1
|
||||
end
|
||||
|
||||
create_table :computers, :force => true do |t|
|
||||
t.integer :developer, :null => false
|
||||
t.integer :extendedWarranty, :null => false
|
||||
end
|
||||
|
||||
|
||||
create_table :customers, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :balance, :default => 0
|
||||
t.string :address_street
|
||||
t.string :address_city
|
||||
t.string :address_country
|
||||
t.string :gps_location
|
||||
end
|
||||
|
||||
create_table :developers, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :salary, :default => 70000
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
end
|
||||
|
||||
create_table :developers_projects, :force => true, :id => false do |t|
|
||||
t.integer :developer_id, :null => false
|
||||
t.integer :project_id, :null => false
|
||||
t.date :joined_on
|
||||
t.integer :access_level, :default => 1
|
||||
end
|
||||
|
||||
create_table :entrants, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
t.integer :course_id, :null => false
|
||||
end
|
||||
|
||||
create_table :funny_jokes, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :keyboards, :force => true, :id => false do |t|
|
||||
t.primary_key :key_number
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :legacy_things, :force => true do |t|
|
||||
t.integer :tps_report_number
|
||||
t.integer :version, :null => false, :default => 0
|
||||
end
|
||||
|
||||
create_table :minimalistics, :force => true do |t|
|
||||
end
|
||||
|
||||
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
||||
t.primary_key :monkeyID
|
||||
t.integer :fleaCount
|
||||
end
|
||||
|
||||
create_table :mixins, :force => true do |t|
|
||||
t.integer :parent_id
|
||||
t.integer :pos
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
t.integer :lft
|
||||
t.integer :rgt
|
||||
t.integer :root_id
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :movies, :force => true, :id => false do |t|
|
||||
t.primary_key :movieid
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :numeric_data, :force => true do |t|
|
||||
t.decimal :bank_balance, :precision => 10, :scale => 2
|
||||
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
||||
t.decimal :world_population, :precision => 10, :scale => 0
|
||||
t.decimal :my_house_population, :precision => 2, :scale => 0
|
||||
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
||||
end
|
||||
|
||||
create_table :orders, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :billing_customer_id
|
||||
t.integer :shipping_customer_id
|
||||
end
|
||||
|
||||
create_table :people, :force => true do |t|
|
||||
t.string :first_name, :null => false
|
||||
t.integer :lock_version, :null => false, :default => 0
|
||||
end
|
||||
|
||||
create_table :posts, :force => true do |t|
|
||||
t.integer :author_id
|
||||
t.string :title, :null => false
|
||||
t.text :body, :null => false
|
||||
t.string :type
|
||||
t.integer :comments_count, :default => 0
|
||||
end
|
||||
|
||||
create_table :projects, :force => true do |t|
|
||||
t.string :name
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :readers, :force => true do |t|
|
||||
t.integer :post_id, :null => false
|
||||
t.integer :person_id, :null => false
|
||||
end
|
||||
|
||||
create_table :subscribers, :force => true, :id => false do |t|
|
||||
t.string :nick, :null => false
|
||||
t.string :name
|
||||
end
|
||||
add_index :subscribers, :nick, :unique => true
|
||||
|
||||
create_table :tasks, :force => true do |t|
|
||||
t.datetime :starting
|
||||
t.datetime :ending
|
||||
end
|
||||
|
||||
create_table :topics, :force => true do |t|
|
||||
t.string :title
|
||||
t.string :author_name
|
||||
t.string :author_email_address
|
||||
t.datetime :written_on
|
||||
t.time :bonus_time
|
||||
t.date :last_read
|
||||
t.text :content
|
||||
t.boolean :approved, :default => true
|
||||
t.integer :replies_count, :default => 0
|
||||
t.integer :parent_id
|
||||
t.string :type
|
||||
end
|
||||
|
||||
|
||||
|
||||
### These tables are created last as the order is significant
|
||||
|
||||
# fk_test_has_fk should be before fk_test_has_pk
|
||||
create_table :fk_test_has_fk, :force => true do |t|
|
||||
t.integer :fk_id, :null => false
|
||||
end
|
||||
|
||||
create_table :fk_test_has_pk, :force => true do |t|
|
||||
end
|
||||
|
||||
execute 'alter table fk_test_has_fk
|
||||
add FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)'
|
||||
|
||||
|
||||
else
|
||||
add_column :posts, :comments_count, :integer, :default => 0
|
||||
end
|
||||
|
||||
# For Firebird, set the sequence values 10000 when create_table is called;
|
||||
# this prevents primary key collisions between "normally" created records
|
||||
# and fixture-based (YAML) records.
|
||||
if adapter_name == "Firebird"
|
||||
#put adapter specific setup here
|
||||
case adapter_name
|
||||
# For Firebird, set the sequence values 10000 when create_table is called;
|
||||
# this prevents primary key collisions between "normally" created records
|
||||
# and fixture-based (YAML) records.
|
||||
when "Firebird"
|
||||
def create_table(*args, &block)
|
||||
ActiveRecord::Base.connection.create_table(*args, &block)
|
||||
ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Please keep these create table statements in alphabetical order
|
||||
# unless the ordering matters. In which case, define them below
|
||||
create_table :accounts, :force => true do |t|
|
||||
t.integer :firm_id
|
||||
t.integer :credit_limit
|
||||
end
|
||||
|
||||
create_table :audit_logs, :force => true do |t|
|
||||
t.column :message, :string, :null=>false
|
||||
t.column :developer_id, :integer, :null=>false
|
||||
end
|
||||
|
||||
create_table :authors, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
t.integer :author_address_id
|
||||
t.integer :author_address_extra_id
|
||||
end
|
||||
|
||||
create_table :author_addresses, :force => true do |t|
|
||||
end
|
||||
|
||||
create_table :author_favorites, :force => true do |t|
|
||||
t.column :author_id, :integer
|
||||
t.column :favorite_author_id, :integer
|
||||
end
|
||||
|
||||
|
||||
create_table :auto_id_tests, :force => true, :id => false do |t|
|
||||
t.primary_key :auto_id
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
create_table :binaries, :force => true do |t|
|
||||
t.binary :data
|
||||
end
|
||||
|
||||
create_table :books, :force => true do |t|
|
||||
t.column :name, :string
|
||||
end
|
||||
|
||||
create_table :booleantests, :force => true do |t|
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
create_table :categories, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :categories_posts, :force => true, :id => false do |t|
|
||||
t.integer :category_id, :null => false
|
||||
t.integer :post_id, :null => false
|
||||
end
|
||||
|
||||
create_table :categorizations, :force => true do |t|
|
||||
t.column :category_id, :integer
|
||||
t.column :post_id, :integer
|
||||
t.column :author_id, :integer
|
||||
end
|
||||
|
||||
create_table :citations, :force => true do |t|
|
||||
t.column :book1_id, :integer
|
||||
t.column :book2_id, :integer
|
||||
end
|
||||
|
||||
create_table :clubs, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :colnametests, :force => true do |t|
|
||||
t.integer :references, :null => false
|
||||
end
|
||||
|
||||
create_table :comments, :force => true do |t|
|
||||
t.integer :post_id, :null => false
|
||||
t.text :body, :null => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :companies, :force => true do |t|
|
||||
t.string :type
|
||||
t.string :ruby_type
|
||||
t.integer :firm_id
|
||||
t.string :name
|
||||
t.integer :client_of
|
||||
t.integer :rating, :default => 1
|
||||
end
|
||||
|
||||
create_table :computers, :force => true do |t|
|
||||
t.integer :developer, :null => false
|
||||
t.integer :extendedWarranty, :null => false
|
||||
end
|
||||
|
||||
|
||||
create_table :customers, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :balance, :default => 0
|
||||
t.string :address_street
|
||||
t.string :address_city
|
||||
t.string :address_country
|
||||
t.string :gps_location
|
||||
end
|
||||
|
||||
create_table :developers, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :salary, :default => 70000
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
end
|
||||
|
||||
create_table :developers_projects, :force => true, :id => false do |t|
|
||||
t.integer :developer_id, :null => false
|
||||
t.integer :project_id, :null => false
|
||||
t.date :joined_on
|
||||
t.integer :access_level, :default => 1
|
||||
end
|
||||
|
||||
create_table :edges, :force => true do |t|
|
||||
t.column :source_id, :integer, :null => false
|
||||
t.column :sink_id, :integer, :null => false
|
||||
end
|
||||
add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
|
||||
|
||||
|
||||
create_table :entrants, :force => true do |t|
|
||||
t.string :name, :null => false
|
||||
t.integer :course_id, :null => false
|
||||
end
|
||||
|
||||
create_table :funny_jokes, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :items, :force => true do |t|
|
||||
t.column :name, :integer
|
||||
end
|
||||
|
||||
create_table :inept_wizards, :force => true do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :city, :string, :null => false
|
||||
t.column :type, :string
|
||||
end
|
||||
|
||||
create_table :keyboards, :force => true, :id => false do |t|
|
||||
t.primary_key :key_number
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :legacy_things, :force => true do |t|
|
||||
t.integer :tps_report_number
|
||||
t.integer :version, :null => false, :default => 0
|
||||
end
|
||||
|
||||
create_table :lock_without_defaults, :force => true do |t|
|
||||
t.column :lock_version, :integer
|
||||
end
|
||||
|
||||
create_table :lock_without_defaults_cust, :force => true do |t|
|
||||
t.column :custom_lock_version, :integer
|
||||
end
|
||||
|
||||
create_table :mateys, :id => false, :force => true do |t|
|
||||
t.column :pirate_id, :integer
|
||||
t.column :target_id, :integer
|
||||
t.column :weight, :integer
|
||||
end
|
||||
|
||||
create_table :members, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :memberships, :force => true do |t|
|
||||
t.datetime :joined_on
|
||||
t.integer :club_id, :member_id
|
||||
t.boolean :favourite, :default => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :minimalistics, :force => true do |t|
|
||||
end
|
||||
|
||||
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
||||
t.primary_key :monkeyID
|
||||
t.integer :fleaCount
|
||||
end
|
||||
|
||||
create_table :mixins, :force => true do |t|
|
||||
t.integer :parent_id
|
||||
t.integer :pos
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
t.integer :lft
|
||||
t.integer :rgt
|
||||
t.integer :root_id
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :movies, :force => true, :id => false do |t|
|
||||
t.primary_key :movieid
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :numeric_data, :force => true do |t|
|
||||
t.decimal :bank_balance, :precision => 10, :scale => 2
|
||||
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
||||
t.decimal :world_population, :precision => 10, :scale => 0
|
||||
t.decimal :my_house_population, :precision => 2, :scale => 0
|
||||
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
||||
end
|
||||
|
||||
create_table :orders, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :billing_customer_id
|
||||
t.integer :shipping_customer_id
|
||||
end
|
||||
|
||||
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
|
||||
create_table :paint_colors, :force => true do |t|
|
||||
t.integer :non_poly_one_id
|
||||
end
|
||||
|
||||
create_table :paint_textures, :force => true do |t|
|
||||
t.integer :non_poly_two_id
|
||||
end
|
||||
|
||||
create_table :parrots, :force => true do |t|
|
||||
t.column :name, :string
|
||||
t.column :parrot_sti_class, :string
|
||||
t.column :killer_id, :integer
|
||||
t.column :created_at, :datetime
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_at, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
end
|
||||
|
||||
create_table :parrots_pirates, :id => false, :force => true do |t|
|
||||
t.column :parrot_id, :integer
|
||||
t.column :pirate_id, :integer
|
||||
end
|
||||
|
||||
create_table :parrots_treasures, :id => false, :force => true do |t|
|
||||
t.column :parrot_id, :integer
|
||||
t.column :treasure_id, :integer
|
||||
end
|
||||
|
||||
create_table :people, :force => true do |t|
|
||||
t.string :first_name, :null => false
|
||||
t.integer :lock_version, :null => false, :default => 0
|
||||
end
|
||||
|
||||
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
|
||||
t.string :name
|
||||
t.integer :owner_id, :integer
|
||||
end
|
||||
|
||||
create_table :pirates, :force => true do |t|
|
||||
t.column :catchphrase, :string
|
||||
t.column :parrot_id, :integer
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
end
|
||||
|
||||
create_table :posts, :force => true do |t|
|
||||
t.integer :author_id
|
||||
t.string :title, :null => false
|
||||
t.text :body, :null => false
|
||||
t.string :type
|
||||
t.integer :comments_count, :default => 0
|
||||
t.integer :taggings_count, :default => 0
|
||||
end
|
||||
|
||||
create_table :price_estimates, :force => true do |t|
|
||||
t.string :estimate_of_type
|
||||
t.integer :estimate_of_id
|
||||
t.integer :price
|
||||
end
|
||||
|
||||
create_table :projects, :force => true do |t|
|
||||
t.string :name
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :readers, :force => true do |t|
|
||||
t.integer :post_id, :null => false
|
||||
t.integer :person_id, :null => false
|
||||
end
|
||||
|
||||
create_table :shape_expressions, :force => true do |t|
|
||||
t.string :paint_type
|
||||
t.integer :paint_id
|
||||
t.string :shape_type
|
||||
t.integer :shape_id
|
||||
end
|
||||
|
||||
create_table :ships, :force => true do |t|
|
||||
t.string :name
|
||||
t.datetime :created_at
|
||||
t.datetime :created_on
|
||||
t.datetime :updated_at
|
||||
t.datetime :updated_on
|
||||
end
|
||||
|
||||
create_table :sponsors, :force => true do |t|
|
||||
t.integer :club_id
|
||||
t.integer :sponsorable_id
|
||||
t.string :sponsorable_type
|
||||
end
|
||||
|
||||
create_table :subscribers, :force => true, :id => false do |t|
|
||||
t.string :nick, :null => false
|
||||
t.string :name
|
||||
end
|
||||
add_index :subscribers, :nick, :unique => true
|
||||
|
||||
create_table :tasks, :force => true do |t|
|
||||
t.datetime :starting
|
||||
t.datetime :ending
|
||||
end
|
||||
|
||||
create_table :topics, :force => true do |t|
|
||||
t.string :title
|
||||
t.string :author_name
|
||||
t.string :author_email_address
|
||||
t.datetime :written_on
|
||||
t.time :bonus_time
|
||||
t.date :last_read
|
||||
t.text :content
|
||||
t.boolean :approved, :default => true
|
||||
t.integer :replies_count, :default => 0
|
||||
t.integer :parent_id
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :taggings, :force => true do |t|
|
||||
t.column :tag_id, :integer
|
||||
t.column :super_tag_id, :integer
|
||||
@@ -245,183 +368,33 @@ ActiveRecord::Schema.define do
|
||||
t.column :taggings_count, :integer, :default => 0
|
||||
end
|
||||
|
||||
create_table :categorizations, :force => true do |t|
|
||||
t.column :category_id, :integer
|
||||
t.column :post_id, :integer
|
||||
t.column :author_id, :integer
|
||||
end
|
||||
|
||||
add_column :posts, :taggings_count, :integer, :default => 0
|
||||
add_column :authors, :author_address_id, :integer
|
||||
add_column :authors, :author_address_extra_id, :integer
|
||||
|
||||
create_table :author_addresses, :force => true do |t|
|
||||
end
|
||||
|
||||
create_table :author_favorites, :force => true do |t|
|
||||
t.column :author_id, :integer
|
||||
t.column :favorite_author_id, :integer
|
||||
end
|
||||
|
||||
create_table :vertices, :force => true do |t|
|
||||
t.column :label, :string
|
||||
end
|
||||
|
||||
create_table :edges, :force => true do |t|
|
||||
t.column :source_id, :integer, :null => false
|
||||
t.column :sink_id, :integer, :null => false
|
||||
end
|
||||
add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
|
||||
|
||||
create_table :lock_without_defaults, :force => true do |t|
|
||||
t.column :lock_version, :integer
|
||||
end
|
||||
|
||||
create_table :lock_without_defaults_cust, :force => true do |t|
|
||||
t.column :custom_lock_version, :integer
|
||||
end
|
||||
|
||||
create_table :items, :force => true do |t|
|
||||
t.column :name, :integer
|
||||
end
|
||||
|
||||
# For sqlite 3.1.0+, make a table with a autoincrement column
|
||||
if adapter_name == 'SQLite' and supports_autoincrement?
|
||||
create_table :table_with_autoincrement, :force => true do |t|
|
||||
t.column :name, :string
|
||||
end
|
||||
end
|
||||
|
||||
# For sqlserver 2000+, ensure real columns can be used
|
||||
if adapter_name.starts_with?("SQLServer")
|
||||
create_table :table_with_real_columns, :force => true do |t|
|
||||
t.column :real_number, :real
|
||||
end
|
||||
end
|
||||
|
||||
create_table :audit_logs, :force => true do |t|
|
||||
t.column :message, :string, :null=>false
|
||||
t.column :developer_id, :integer, :null=>false
|
||||
end
|
||||
|
||||
create_table :books, :force => true do |t|
|
||||
t.column :name, :string
|
||||
end
|
||||
|
||||
create_table :citations, :force => true do |t|
|
||||
t.column :book1_id, :integer
|
||||
t.column :book2_id, :integer
|
||||
end
|
||||
|
||||
create_table :inept_wizards, :force => true do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :city, :string, :null => false
|
||||
t.column :type, :string
|
||||
end
|
||||
|
||||
create_table :parrots, :force => true do |t|
|
||||
t.column :name, :string
|
||||
t.column :parrot_sti_class, :string
|
||||
t.column :killer_id, :integer
|
||||
t.column :created_at, :datetime
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_at, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
end
|
||||
|
||||
create_table :pirates, :force => true do |t|
|
||||
t.column :catchphrase, :string
|
||||
t.column :parrot_id, :integer
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
end
|
||||
|
||||
create_table :parrots_pirates, :id => false, :force => true do |t|
|
||||
t.column :parrot_id, :integer
|
||||
t.column :pirate_id, :integer
|
||||
end
|
||||
|
||||
create_table :treasures, :force => true do |t|
|
||||
t.column :name, :string
|
||||
t.column :looter_id, :integer
|
||||
t.column :looter_type, :string
|
||||
end
|
||||
|
||||
create_table :parrots_treasures, :id => false, :force => true do |t|
|
||||
t.column :parrot_id, :integer
|
||||
t.column :treasure_id, :integer
|
||||
end
|
||||
|
||||
create_table :mateys, :id => false, :force => true do |t|
|
||||
t.column :pirate_id, :integer
|
||||
t.column :target_id, :integer
|
||||
t.column :weight, :integer
|
||||
end
|
||||
|
||||
create_table :ships, :force => true do |t|
|
||||
t.string :name
|
||||
t.datetime :created_at
|
||||
t.datetime :created_on
|
||||
t.datetime :updated_at
|
||||
t.datetime :updated_on
|
||||
create_table :vertices, :force => true do |t|
|
||||
t.column :label, :string
|
||||
end
|
||||
|
||||
create_table 'warehouse-things', :force => true do |t|
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
|
||||
t.string :name
|
||||
t.integer :owner_id, :integer
|
||||
end
|
||||
|
||||
create_table :price_estimates, :force => true do |t|
|
||||
t.string :estimate_of_type
|
||||
t.integer :estimate_of_id
|
||||
t.integer :price
|
||||
end
|
||||
|
||||
[:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
|
||||
create_table(t, :force => true) { }
|
||||
end
|
||||
|
||||
create_table :shape_expressions, :force => true do |t|
|
||||
t.string :paint_type
|
||||
t.integer :paint_id
|
||||
t.string :shape_type
|
||||
t.integer :shape_id
|
||||
end
|
||||
except 'SQLite' do
|
||||
# fk_test_has_fk should be before fk_test_has_pk
|
||||
create_table :fk_test_has_fk, :force => true do |t|
|
||||
t.integer :fk_id, :null => false
|
||||
end
|
||||
|
||||
create_table :paint_colors, :force => true do |t|
|
||||
t.integer :non_poly_one_id
|
||||
end
|
||||
create_table :fk_test_has_pk, :force => true do |t|
|
||||
end
|
||||
|
||||
create_table :paint_textures, :force => true do |t|
|
||||
t.integer :non_poly_two_id
|
||||
end
|
||||
|
||||
create_table :clubs, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :members, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :memberships, :force => true do |t|
|
||||
t.datetime :joined_on
|
||||
t.integer :club_id, :member_id
|
||||
t.boolean :favourite, :default => false
|
||||
t.string :type
|
||||
end
|
||||
|
||||
create_table :sponsors, :force => true do |t|
|
||||
t.integer :club_id
|
||||
t.integer :sponsorable_id
|
||||
t.string :sponsorable_type
|
||||
execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
ActiveRecord::Schema.define do
|
||||
|
||||
# adapter name is checked because we are under a transition of
|
||||
# moving the sql files under activerecord/test/fixtures/db_definitions
|
||||
# to this file, schema.rb.
|
||||
if adapter_name == "MySQL"
|
||||
Course.connection.create_table :courses, :force => true do |t|
|
||||
t.column :name, :string, :null => false
|
||||
end
|
||||
Course.connection.create_table :courses, :force => true do |t|
|
||||
t.column :name, :string, :null => false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
DROP TABLE accounts;
|
||||
DROP TABLE funny_jokes;
|
||||
DROP TABLE companies;
|
||||
DROP TABLE topics;
|
||||
DROP TABLE developers;
|
||||
DROP TABLE projects;
|
||||
DROP TABLE developers_projects;
|
||||
DROP TABLE customers;
|
||||
DROP TABLE orders;
|
||||
DROP TABLE movies;
|
||||
DROP TABLE subscribers;
|
||||
DROP TABLE booleantests;
|
||||
DROP TABLE auto_id_tests;
|
||||
DROP TABLE entrants;
|
||||
DROP TABLE colnametests;
|
||||
DROP TABLE mixins;
|
||||
DROP TABLE people;
|
||||
DROP TABLE readers;
|
||||
DROP TABLE binaries;
|
||||
DROP TABLE computers;
|
||||
DROP TABLE tasks;
|
||||
DROP TABLE posts;
|
||||
DROP TABLE comments;
|
||||
DROP TABLE authors;
|
||||
DROP TABLE categories;
|
||||
DROP TABLE categories_posts;
|
||||
DROP TABLE fk_test_has_fk;
|
||||
DROP TABLE fk_test_has_pk;
|
||||
DROP TABLE keyboards;
|
||||
DROP TABLE legacy_things;
|
||||
DROP TABLE numeric_data;
|
||||
DROP TABLE mixed_case_monkeys;
|
||||
DROP TABLE minimalistics;
|
||||
@@ -1,219 +0,0 @@
|
||||
CREATE TABLE 'accounts' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'firm_id' INTEGER DEFAULT NULL,
|
||||
'credit_limit' INTEGER DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'funny_jokes' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' TEXT DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'companies' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL,
|
||||
'ruby_type' VARCHAR(255) DEFAULT NULL,
|
||||
'firm_id' INTEGER DEFAULT NULL,
|
||||
'name' TEXT DEFAULT NULL,
|
||||
'client_of' INTEGER DEFAULT NULL,
|
||||
'rating' INTEGER DEFAULT 1
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE 'topics' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'title' VARCHAR(255) DEFAULT NULL,
|
||||
'author_name' VARCHAR(255) DEFAULT NULL,
|
||||
'author_email_address' VARCHAR(255) DEFAULT NULL,
|
||||
'written_on' DATETIME DEFAULT NULL,
|
||||
'bonus_time' TIME DEFAULT NULL,
|
||||
'last_read' DATE DEFAULT NULL,
|
||||
'content' TEXT,
|
||||
'approved' boolean DEFAULT 't',
|
||||
'replies_count' INTEGER DEFAULT 0,
|
||||
'parent_id' INTEGER DEFAULT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'developers' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' TEXT DEFAULT NULL,
|
||||
'salary' INTEGER DEFAULT 70000,
|
||||
'created_at' DATETIME DEFAULT NULL,
|
||||
'updated_at' DATETIME DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'projects' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' TEXT DEFAULT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'developers_projects' (
|
||||
'developer_id' INTEGER NOT NULL,
|
||||
'project_id' INTEGER NOT NULL,
|
||||
'joined_on' DATE DEFAULT NULL,
|
||||
'access_level' INTEGER DEFAULT 1
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE 'orders' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' VARCHAR(255) DEFAULT NULL,
|
||||
'billing_customer_id' INTEGER DEFAULT NULL,
|
||||
'shipping_customer_id' INTEGER DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'customers' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' VARCHAR(255) DEFAULT NULL,
|
||||
'balance' INTEGER DEFAULT 0,
|
||||
'address_street' TEXT DEFAULT NULL,
|
||||
'address_city' TEXT DEFAULT NULL,
|
||||
'address_country' TEXT DEFAULT NULL,
|
||||
'gps_location' TEXT DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'movies' (
|
||||
'movieid' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
'nick' VARCHAR(255) PRIMARY KEY NOT NULL,
|
||||
'name' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'booleantests' (
|
||||
'id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'value' INTEGER DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'auto_id_tests' (
|
||||
'auto_id' INTEGER PRIMARY KEY NOT NULL,
|
||||
'value' INTEGER DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'entrants' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'name' VARCHAR(255) NOT NULL,
|
||||
'course_id' INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'colnametests' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'references' INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'mixins' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'parent_id' INTEGER DEFAULT NULL,
|
||||
'type' VARCHAR(40) DEFAULT NULL,
|
||||
'pos' INTEGER DEFAULT NULL,
|
||||
'lft' INTEGER DEFAULT NULL,
|
||||
'rgt' INTEGER DEFAULT NULL,
|
||||
'root_id' INTEGER DEFAULT NULL,
|
||||
'created_at' DATETIME DEFAULT NULL,
|
||||
'updated_at' DATETIME DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'people' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'first_name' VARCHAR(40) DEFAULT NULL,
|
||||
'lock_version' INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE 'readers' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'post_id' INTEGER NOT NULL,
|
||||
'person_id' INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'binaries' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'data' BLOB DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'computers' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'developer' INTEGER NOT NULL,
|
||||
'extendedWarranty' INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'posts' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'author_id' INTEGER,
|
||||
'title' VARCHAR(255) NOT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL,
|
||||
'body' TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'comments' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'post_id' INTEGER NOT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL,
|
||||
'body' TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'authors' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'name' VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'tasks' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'starting' DATETIME DEFAULT NULL,
|
||||
'ending' DATETIME DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'categories' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'name' VARCHAR(255) NOT NULL,
|
||||
'type' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'categories_posts' (
|
||||
'category_id' INTEGER NOT NULL,
|
||||
'post_id' INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE 'fk_test_has_pk' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE 'fk_test_has_fk' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'fk_id' INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id')
|
||||
);
|
||||
|
||||
CREATE TABLE 'keyboards' (
|
||||
'key_number' INTEGER PRIMARY KEY NOT NULL,
|
||||
'name' VARCHAR(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
--Altered lock_version column name.
|
||||
CREATE TABLE 'legacy_things' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'tps_report_number' INTEGER DEFAULT NULL,
|
||||
'version' INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE 'numeric_data' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'bank_balance' DECIMAL(10,2),
|
||||
'big_bank_balance' DECIMAL(15,2),
|
||||
'world_population' DECIMAL(10),
|
||||
'my_house_population' DECIMAL(2),
|
||||
'decimal_number_with_default' DECIMAL(3,2) DEFAULT 2.78
|
||||
);
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
'monkeyID' INTEGER NOT NULL PRIMARY KEY,
|
||||
'fleaCount' INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
DROP TABLE courses;
|
||||
@@ -1,4 +0,0 @@
|
||||
CREATE TABLE 'courses' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'name' VARCHAR(255) NOT NULL
|
||||
);
|
||||
25
activerecord/test/schema/sqlite_specific_schema.rb
Normal file
25
activerecord/test/schema/sqlite_specific_schema.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
ActiveRecord::Schema.define do
|
||||
# For sqlite 3.1.0+, make a table with a autoincrement column
|
||||
if supports_autoincrement?
|
||||
create_table :table_with_autoincrement, :force => true do |t|
|
||||
t.column :name, :string
|
||||
end
|
||||
end
|
||||
|
||||
execute "DROP TABLE fk_test_has_fk" rescue nil
|
||||
execute "DROP TABLE fk_test_has_pk" rescue nil
|
||||
execute <<_SQL
|
||||
CREATE TABLE 'fk_test_has_pk' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY
|
||||
);
|
||||
_SQL
|
||||
|
||||
execute <<_SQL
|
||||
CREATE TABLE 'fk_test_has_fk' (
|
||||
'id' INTEGER NOT NULL PRIMARY KEY,
|
||||
'fk_id' INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id')
|
||||
);
|
||||
_SQL
|
||||
end
|
||||
5
activerecord/test/schema/sqlserver_specific_schema.rb
Normal file
5
activerecord/test/schema/sqlserver_specific_schema.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
ActiveRecord::Schema.define do
|
||||
create_table :table_with_real_columns, :force => true do |t|
|
||||
t.column :real_number, :real
|
||||
end
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
DROP TABLE accounts
|
||||
DROP TABLE funny_jokes
|
||||
DROP TABLE companies
|
||||
DROP TABLE topics
|
||||
DROP TABLE developers
|
||||
DROP TABLE projects
|
||||
DROP TABLE developers_projects
|
||||
DROP TABLE customers
|
||||
DROP TABLE orders
|
||||
DROP TABLE movies
|
||||
DROP TABLE subscribers
|
||||
DROP TABLE booleantests
|
||||
DROP TABLE auto_id_tests
|
||||
DROP TABLE entrants
|
||||
DROP TABLE colnametests
|
||||
DROP TABLE mixins
|
||||
DROP TABLE people
|
||||
DROP TABLE readers
|
||||
DROP TABLE binaries
|
||||
DROP TABLE computers
|
||||
DROP TABLE tasks
|
||||
DROP TABLE posts
|
||||
DROP TABLE comments
|
||||
DROP TABLE authors
|
||||
DROP TABLE categories
|
||||
DROP TABLE categories_posts
|
||||
DROP TABLE fk_test_has_fk
|
||||
DROP TABLE fk_test_has_pk
|
||||
DROP TABLE keyboards
|
||||
DROP TABLE legacy_things
|
||||
DROP TABLE numeric_data
|
||||
DROP TABLE mixed_case_monkeys
|
||||
DROP TABLE minimalistics
|
||||
DROP TABLE schema_migrations
|
||||
go
|
||||
@@ -1,222 +0,0 @@
|
||||
CREATE TABLE accounts (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
firm_id int NULL,
|
||||
credit_limit int NULL
|
||||
)
|
||||
|
||||
CREATE TABLE funny_jokes (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(50) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE companies (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
type varchar(50) NULL,
|
||||
ruby_type varchar(50) NULL,
|
||||
firm_id int NULL,
|
||||
name varchar(50) NULL,
|
||||
client_of int NULL,
|
||||
rating int default 1
|
||||
)
|
||||
|
||||
|
||||
CREATE TABLE topics (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
title varchar(255) NULL,
|
||||
author_name varchar(255) NULL,
|
||||
author_email_address varchar(255) NULL,
|
||||
written_on datetime NULL,
|
||||
bonus_time datetime NULL,
|
||||
last_read datetime NULL,
|
||||
content varchar(255) NULL,
|
||||
approved bit default 1,
|
||||
replies_count int default 0,
|
||||
parent_id int NULL,
|
||||
type varchar(50) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE developers (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(100) NULL,
|
||||
salary int default 70000,
|
||||
created_at datetime NULL,
|
||||
updated_at datetime NULL
|
||||
)
|
||||
|
||||
CREATE TABLE projects (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(100) NULL,
|
||||
type varchar(255) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE developers_projects (
|
||||
developer_id int NOT NULL,
|
||||
project_id int NOT NULL,
|
||||
joined_on datetime NULL,
|
||||
access_level smallint default 1
|
||||
)
|
||||
|
||||
CREATE TABLE orders (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(100) NULL,
|
||||
billing_customer_id int NULL,
|
||||
shipping_customer_id int NULL
|
||||
)
|
||||
|
||||
CREATE TABLE customers (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(100) NULL,
|
||||
balance int default 0,
|
||||
address_street varchar(100) NULL,
|
||||
address_city varchar(100) NULL,
|
||||
address_country varchar(100) NULL,
|
||||
gps_location varchar(100) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE movies (
|
||||
movieid numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(100) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE subscribers (
|
||||
nick varchar(100) PRIMARY KEY,
|
||||
name varchar(100) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE booleantests (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
value int NULL
|
||||
)
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
auto_id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
value int NULL
|
||||
)
|
||||
|
||||
CREATE TABLE entrants (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
course_id int NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE colnametests (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
[references] int NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE mixins (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
parent_id int NULL,
|
||||
pos int NULL,
|
||||
created_at datetime NULL,
|
||||
updated_at datetime NULL,
|
||||
lft int NULL,
|
||||
rgt int NULL,
|
||||
root_id int NULL,
|
||||
type varchar(40) NULL
|
||||
)
|
||||
|
||||
CREATE TABLE people (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
first_name varchar(40) NULL,
|
||||
lock_version int DEFAULT 0
|
||||
)
|
||||
|
||||
CREATE TABLE readers (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
post_id int NOT NULL,
|
||||
person_id int NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE binaries (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
data image NULL
|
||||
)
|
||||
|
||||
CREATE TABLE computers (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
developer int NOT NULL,
|
||||
extendedWarranty int NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE posts (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
author_id int NULL,
|
||||
title varchar(255) NOT NULL,
|
||||
body varchar(2048) NOT NULL,
|
||||
type varchar(255) NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE comments (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
post_id int NOT NULL,
|
||||
body varchar(2048) NOT NULL,
|
||||
type varchar(255) NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE authors (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(255) NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
starting datetime NULL,
|
||||
ending datetime NULL
|
||||
)
|
||||
|
||||
CREATE TABLE categories (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
type varchar(255) NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE categories_posts (
|
||||
category_id int NOT NULL,
|
||||
post_id int NOT NULL
|
||||
)
|
||||
|
||||
CREATE TABLE fk_test_has_pk (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY
|
||||
)
|
||||
|
||||
CREATE TABLE fk_test_has_fk (
|
||||
id numeric(9,0) PRIMARY KEY,
|
||||
fk_id numeric(9,0) NOT NULL,
|
||||
|
||||
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
||||
)
|
||||
|
||||
|
||||
CREATE TABLE keyboards (
|
||||
key_number numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
name varchar(50) NULL
|
||||
)
|
||||
|
||||
--This table has an altered lock_version column name.
|
||||
CREATE TABLE legacy_things (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
tps_report_number int default NULL,
|
||||
version int default 0
|
||||
)
|
||||
|
||||
|
||||
CREATE TABLE numeric_data (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
bank_balance numeric(10,2),
|
||||
big_bank_balance numeric(15,2),
|
||||
world_population numeric(10),
|
||||
my_house_population numeric(2),
|
||||
decimal_number_with_default numeric(3,2) DEFAULT 2.78
|
||||
)
|
||||
|
||||
CREATE TABLE mixed_case_monkeys (
|
||||
[monkeyID] numeric(9,0) IDENTITY PRIMARY KEY,
|
||||
[fleaCount] numeric(9,0)
|
||||
);
|
||||
|
||||
CREATE TABLE minimalistics (
|
||||
id numeric(9,0) IDENTITY PRIMARY KEY
|
||||
);
|
||||
|
||||
go
|
||||
@@ -1,2 +0,0 @@
|
||||
DROP TABLE courses
|
||||
go
|
||||
@@ -1,5 +0,0 @@
|
||||
CREATE TABLE courses (
|
||||
id int NOT NULL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL
|
||||
)
|
||||
go
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user