Initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
class UsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :users do
|
||||
primary_key :id
|
||||
String :email, :null => false, :unique => true
|
||||
String :crypted_password, :null => false
|
||||
String :salt, :null => false
|
||||
String :database_name
|
||||
String :username, :unique => true, :null => false
|
||||
Integer :tables_count, :null => false
|
||||
end
|
||||
|
||||
alter_table(:users) do
|
||||
set_column_default :tables_count, 0
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :users
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
class UserTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :user_tables do
|
||||
primary_key :id
|
||||
Integer :user_id, :null => false, :index => true
|
||||
String :name, :null => false
|
||||
Integer :privacy, :null => false
|
||||
DateTime :updated_at, :null => false
|
||||
String :tags, :text => true
|
||||
String :geometry_columns
|
||||
Integer :rows_counted
|
||||
Integer :rows_estimated
|
||||
end
|
||||
|
||||
alter_table(:user_tables) do
|
||||
add_index [:user_id, :privacy]
|
||||
add_index [:name, :user_id], :unique => true
|
||||
set_column_default :privacy, 0
|
||||
set_column_default :rows_counted, 0
|
||||
set_column_default :rows_estimated, 0
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :user_tables
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class TagsMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :tags do
|
||||
primary_key :id
|
||||
String :name, :null => false
|
||||
Integer :user_id, :null => false, :index => true
|
||||
Integer :table_id, :null => false, :index => true
|
||||
index [:user_id, :table_id, :name], :unique => true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :tags
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
class ApiKeysMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :api_keys do
|
||||
primary_key :id
|
||||
String :api_key, :null => false, :unique => true, :index => true
|
||||
Integer :user_id, :null => false
|
||||
String :domain, :null => false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :api_keys
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
class CreateOauthTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :client_applications do
|
||||
primary_key :id
|
||||
String :name
|
||||
String :url
|
||||
String :support_url
|
||||
String :callback_url
|
||||
String :key, :limit => 40, :unique => true
|
||||
String :secret, :limit => 40
|
||||
Integer :user_id
|
||||
DateTime :created_at, :null => false
|
||||
DateTime :updated_at, :null => false
|
||||
end
|
||||
|
||||
create_table :oauth_tokens do
|
||||
primary_key :id
|
||||
Integer :user_id
|
||||
String :type, :limit => 20
|
||||
Integer :client_application_id
|
||||
String :token, :limit => 40, :unique => true
|
||||
String :secret, :limit => 40
|
||||
String :callback_url
|
||||
String :verifier, :limit => 20
|
||||
String :scope
|
||||
DateTime :authorized_at
|
||||
DateTime :invalidated_at
|
||||
DateTime :valid_to
|
||||
DateTime :created_at, :null => false
|
||||
DateTime :updated_at, :null => false
|
||||
end
|
||||
|
||||
create_table :oauth_nonces do
|
||||
primary_key :id
|
||||
String :nonce
|
||||
Integer :timestamp
|
||||
DateTime :created_at, :null => false
|
||||
DateTime :updated_at, :null => false
|
||||
index [:nonce, :timestamp], :unique => true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :client_applications
|
||||
drop_table :oauth_tokens
|
||||
drop_table :oauth_nonces
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddAdminFlagToUsersMigration < Sequel::Migration
|
||||
def up
|
||||
add_column :users, :admin, :boolean
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :admin
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddEnabledFieldToUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :enabled, :boolean, :default => false
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :enabled
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddTableIndexesMetadataMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :indexes, 'character varying[]'
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :indexes
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddSchemaToTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :stored_schema, 'character varying[]'
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :stored_schema
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddTheGeomTypeToTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :the_geom_type, 'character varying'
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :the_geom_type
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class AddInviteTokenToUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :invite_token, String
|
||||
add_column :users, :invite_token_date, Date
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :invite_token
|
||||
drop_column :users, :invite_token_date
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class RemoveStoredSchemaFromUserTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
drop_column :user_tables, :stored_schema
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :user_tables, :stored_schema, 'character varying[]'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddDatabaseNameToUserTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :database_name, String
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :database_name
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class DropColumTheGeomTypeMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
drop_column :user_tables, :the_geom_type
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :user_tables, :the_geom_type, 'character varying'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class AddSubdomainsMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :subdomain, 'character varying'
|
||||
|
||||
alter_table(:users) do
|
||||
add_index [:subdomain], :unique => true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :subdomain
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddMapEnabledToUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :map_enabled, :boolean, :default => true
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :map_enabled
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class ChangeDefaultEnabledInUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
alter_table(:users) do
|
||||
set_column_default :enabled, true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
alter_table(:users) do
|
||||
set_column_default :enabled, false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class RemoveSubdomainFromUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
drop_column :users, :subdomain
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :users, :subdomain, 'character varying'
|
||||
alter_table(:users) do
|
||||
add_index [:subdomain], :unique => true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddQuotaToUserMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :quota_in_bytes, :bigint, :default => 104857600
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :quota_in_bytes
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class AddTableQuotaAndAccountTypeToUser < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :users, :table_quota, :bigint, :default => 5
|
||||
add_column :users, :account_type, String, :default => 'FREE'
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :table_quota
|
||||
drop_column :users, :account_type
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddPrivateTablesToUserMigration < Sequel::Migration
|
||||
def up
|
||||
add_column :users, :private_tables_enabled, :boolean, :default => false
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :users, :private_tables_enabled
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
class AddDataImportToManagamentDbMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :data_imports do
|
||||
primary_key :id
|
||||
Integer :user_id, :null=>false
|
||||
Integer :table_id
|
||||
String :data_source, :text=>true
|
||||
String :data_type, :text=>true
|
||||
String :table_name, :text=>true
|
||||
String :state, :text=>true, :null=>false
|
||||
Boolean :success, :null=>false
|
||||
Text :logger, :text=>true, :null=>false
|
||||
DateTime :updated_at, :null=>false
|
||||
DateTime :created_at
|
||||
end
|
||||
alter_table(:data_imports) do
|
||||
add_index [:user_id, :table_id], :unique => true
|
||||
add_index [:user_id]
|
||||
add_index [:table_id]
|
||||
add_index [:state]
|
||||
set_column_default :logger, "Begin:\n"
|
||||
set_column_default :success, false
|
||||
set_column_default :created_at, Time.now
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :data_imports
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddDataImportIdColToUserTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :data_import_id, :bigint
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :data_import_id
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddNewErrorCodeColumnToDataImportMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :data_imports, :error_code, :integer
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :data_imports, :error_code
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class ChangeDataImportTimestampDefaultMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
alter_table(:data_imports) do
|
||||
set_column_default :created_at, Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddQueueIdToDataImportsMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :data_imports, :queue_id, String
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :data_imports, :queue_id
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
class MapsMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :maps do
|
||||
primary_key :id
|
||||
Integer :user_id, :null => false, :index => true
|
||||
String :provider, :text => true
|
||||
String :bounding_box_sw, :text => true
|
||||
String :bounding_box_ne, :text => true
|
||||
String :center, :text => true
|
||||
Integer :zoom
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :maps
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class LayersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :layers do
|
||||
primary_key :id
|
||||
String :options, :text => true
|
||||
String :kind, :text => true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :layers
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class LayersMapsMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :layers_maps do
|
||||
primary_key :id
|
||||
foreign_key :layer_id, :layers
|
||||
foreign_key :map_id, :maps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :layers_maps
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddMapIdToTablesMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
add_column :user_tables, :map_id, :bigint
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :user_tables, :map_id
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :user_tables do
|
||||
add_column :description, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :layers do
|
||||
add_column :infowindow, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
end
|
||||
|
||||
down do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
end
|
||||
|
||||
down do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :last_active_time, :timestamp
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class LayersUsersMigration < Sequel::Migration
|
||||
|
||||
def up
|
||||
create_table :layers_users do
|
||||
primary_key :id
|
||||
foreign_key :layer_id, :layers
|
||||
foreign_key :user_id, :users
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :layers_users
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :layers do
|
||||
add_column :order, :integer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :maps do
|
||||
add_column :view_bounds_sw, :text
|
||||
add_column :view_bounds_ne, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :user_tables do
|
||||
add_column :table_id, Integer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
create_table :assets do
|
||||
primary_key :id
|
||||
Integer :user_id, :null => false, :index => true
|
||||
String :public_url, :text => true
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table :assets
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
drop_column :users, :last_active_time
|
||||
end
|
||||
|
||||
down do
|
||||
add_column :users, :last_active_time, :timestamp
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
#require Rails.root.join('lib/cartodb/migrator20')
|
||||
|
||||
#Migrator20.new.migrate!
|
||||
end
|
||||
|
||||
down do
|
||||
#Table.select(:id, :database_name, :name, :user_id).all.each do |table|
|
||||
# $tables_metadata.hset(table.key, 'migrated_to_20', false)
|
||||
#end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
Tag.db.run("DELETE FROM tags where name = ''")
|
||||
end
|
||||
|
||||
down do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :data_imports do
|
||||
add_column :tables_created_count, Integer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :data_imports do
|
||||
add_column :table_names, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :layers do
|
||||
add_column :updated_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :maps do
|
||||
add_column :updated_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class AddDefaultToLayersUpdatedAt < Sequel::Migration
|
||||
def up
|
||||
SequelRails.connection.run("ALTER TABLE layers ALTER COLUMN updated_at SET DEFAULT NOW()")
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
SequelRails.connection.run("UPDATE layers SET updated_at = NOW() WHERE updated_at IS NULL")
|
||||
end
|
||||
|
||||
down do
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :data_imports do
|
||||
add_column :append, :boolean
|
||||
add_column :migrate_table, :text
|
||||
add_column :table_copy, :text
|
||||
add_column :from_query, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
class VisualizationsMigration < Sequel::Migration
|
||||
def up
|
||||
create_table :visualizations do
|
||||
String :id, null: false, primary_key: true
|
||||
String :name, text: true
|
||||
String :description, text: true
|
||||
String :map_id, index: true
|
||||
String :type
|
||||
end
|
||||
end #up
|
||||
|
||||
def down
|
||||
drop_table :visualizations
|
||||
end #down
|
||||
end # VisualizationsMigration
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class OverlaysMigration < Sequel::Migration
|
||||
def up
|
||||
create_table :overlays do
|
||||
String :id, null: false, primary_key: true
|
||||
Integer :order, null: false
|
||||
String :options, text: true
|
||||
String :visualization_id, index: true
|
||||
end
|
||||
end #up
|
||||
|
||||
def down
|
||||
drop_table :overlays
|
||||
end #down
|
||||
end # OverlaysMigration
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class VisualizationsTagsMigration < Sequel::Migration
|
||||
def up
|
||||
SequelRails.connection.run(%q{
|
||||
ALTER TABLE "visualizations"
|
||||
ADD COLUMN tags text[]
|
||||
})
|
||||
end #up
|
||||
|
||||
def down
|
||||
drop_column :visualizations, :tags
|
||||
end #down
|
||||
end #VisualizationsTagsMigration
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :overlays do
|
||||
add_column :type, String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class VisualizationsFixMigration < Sequel::Migration
|
||||
def up
|
||||
SequelRails.connection.run(%Q{
|
||||
ALTER TABLE visualizations
|
||||
ALTER COLUMN map_id
|
||||
TYPE integer
|
||||
USING map_id::integer
|
||||
})
|
||||
end #up
|
||||
|
||||
def down
|
||||
end #down
|
||||
end # VisualizationsFixMigration
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :visualizations do
|
||||
add_column :active_layer_id, Integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :visualizations do
|
||||
add_column :privacy, String
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :visualizations do
|
||||
set_column_default :created_at, Sequel::CURRENT_TIMESTAMP
|
||||
set_column_default :updated_at, Sequel::CURRENT_TIMESTAMP
|
||||
add_column :created_at, DateTime
|
||||
add_column :updated_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
create_table :layers_user_tables do
|
||||
primary_key :id
|
||||
foreign_key :layer_id, :layers
|
||||
foreign_key :user_table_id, :user_tables
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table :layers_user_tables
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class AddPeriodEndDateToUsers < Sequel::Migration
|
||||
def up
|
||||
alter_table :users do
|
||||
add_column :period_end_date, DateTime
|
||||
set_column_default :period_end_date, Sequel.function(:now)
|
||||
end
|
||||
end #up
|
||||
|
||||
def down
|
||||
alter_table :users do
|
||||
drop_column :period_end_date
|
||||
end
|
||||
end #down
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :map_view_quota, :integer, :default => 10000
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :max_layers, :integer, :default => 3
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
class IncreaseDefaultUserMaxLayers < Sequel::Migration
|
||||
def up
|
||||
alter_table :users do
|
||||
set_column_default :max_layers, 4
|
||||
end
|
||||
::User.db.run("UPDATE users set max_layers = 4")
|
||||
end #up
|
||||
|
||||
def down
|
||||
alter_table :users do
|
||||
set_column_default :max_layers, 3
|
||||
end
|
||||
::User.db.run("UPDATE users set max_layers = 3")
|
||||
end #down
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :database_timeout, :integer, :default => 300000
|
||||
add_column :user_timeout, :integer, :default => 300000
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :assets do
|
||||
add_column :kind, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :upgraded_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :map_view_block_price, :integer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :geocoding_quota, :integer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
|
||||
create_table :geocodings do
|
||||
primary_key :id
|
||||
Integer :user_id
|
||||
Text :table_name
|
||||
Integer :total_rows
|
||||
Integer :processed_rows
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :geocodings do
|
||||
add_column :remote_id, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :geocodings do
|
||||
add_column :formatter, :text
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :dashboard_viewed_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
class SynchronizationsMigration < Sequel::Migration
|
||||
def up
|
||||
create_table :synchronizations do
|
||||
String :id, null: false, primary_key: true
|
||||
String :name, text: true
|
||||
Integer :interval
|
||||
String :url, text: true
|
||||
String :state
|
||||
Integer :user_id
|
||||
DateTime :created_at, null: false
|
||||
DateTime :updated_at, null: false
|
||||
DateTime :run_at
|
||||
DateTime :runned_at
|
||||
Integer :retried_times
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :synchronizations
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddSynchronizationIdToDataImport < Sequel::Migration
|
||||
def up
|
||||
add_column :data_imports, :synchronization_id, String
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :data_imports, :synchronization_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :sync_tables_enabled, :boolean, :default => false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
class AddLogAndErrorCodeToSynchronization < Sequel::Migration
|
||||
def up
|
||||
alter_table :synchronizations do
|
||||
add_column :log_id, String
|
||||
add_column :error_code, Integer
|
||||
add_column :error_message, String, text: true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
alter_table :synchronizations do
|
||||
drop_column :log_id
|
||||
drop_column :error_code
|
||||
drop_column :error_message
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
class ChangeSynchronizationRunnedAtToRanAt < Sequel::Migration
|
||||
def up
|
||||
alter_table :synchronizations do
|
||||
drop_column :runned_at
|
||||
add_column :ran_at, DateTime
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
alter_table :synchronizations do
|
||||
drop_column :ran_at
|
||||
add_column :runned_at, DateTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
Sequel.migration do
|
||||
|
||||
TABLE_LIST = {
|
||||
'client_applications' => ['created_at', 'updated_at'],
|
||||
'data_imports' => ['created_at', 'updated_at'],
|
||||
'geocodings' => ['created_at', 'updated_at'],
|
||||
'layers' => ['updated_at'],
|
||||
'maps' => ['updated_at'],
|
||||
'oauth_nonces' => ['created_at', 'updated_at'],
|
||||
'oauth_tokens' => ['created_at', 'updated_at', 'authorized_at', 'invalidated_at', 'valid_to'],
|
||||
'synchronizations' => ['created_at', 'updated_at', 'run_at', 'ran_at'],
|
||||
'user_tables' => ['updated_at'],
|
||||
'users' => ['period_end_date', 'upgraded_at', 'dashboard_viewed_at'],
|
||||
'visualizations' => ['created_at', 'updated_at']
|
||||
}
|
||||
|
||||
up do
|
||||
TABLE_LIST.each do |table_name,columns|
|
||||
columns.each do |column|
|
||||
SequelRails.connection.run(%Q{
|
||||
ALTER TABLE #{table_name}
|
||||
ALTER COLUMN #{column}
|
||||
TYPE timestamptz
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
TABLE_LIST.each do |table_name,columns|
|
||||
columns.each do |column|
|
||||
SequelRails.connection.run(%Q{
|
||||
ALTER TABLE #{table_name}
|
||||
ALTER COLUMN #{column}
|
||||
TYPE timestamp
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class AddModifiedAtEtagAndChecksumToSynchronization < Sequel::Migration
|
||||
def up
|
||||
alter_table :synchronizations do
|
||||
add_column :modified_at, DateTime
|
||||
add_column :etag, String
|
||||
add_column :checksum, String
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
alter_table :synchronizations do
|
||||
drop_column :modified_at
|
||||
drop_column :etag
|
||||
drop_column :checksum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Sequel.migration do
|
||||
|
||||
CONFIG_DATABASE_HOST = ::SequelRails.configuration.environment_for(Rails.env)['host']
|
||||
|
||||
up do
|
||||
add_column :users, :database_host, String
|
||||
SequelRails.connection.run(%Q{
|
||||
UPDATE users
|
||||
SET database_host='#{CONFIG_DATABASE_HOST}'
|
||||
WHERE database_host IS NULL
|
||||
})
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :users, :database_host
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
alter_table :users do
|
||||
add_column :geocoding_block_price, :integer
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table :users do
|
||||
drop_column :geocoding_block_price
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
alter_table :geocodings do
|
||||
add_column :state, :text
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table :geocodings do
|
||||
drop_column :state
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
alter_table :geocodings do
|
||||
set_column_default :processed_rows, 0
|
||||
set_column_default :total_rows, 0
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table :geocodings do
|
||||
set_column_default :processed_rows, nil
|
||||
set_column_default :total_rows, nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
drop_table :api_keys
|
||||
end
|
||||
|
||||
down do
|
||||
create_table :api_keys do
|
||||
primary_key :id
|
||||
String :api_key, null: false, unique: true, index: true
|
||||
Integer :user_id, null: false
|
||||
String :domain, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :users, :api_key, :text
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :users, :api_key
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :users, :notification, :text
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :users, :notification, :text
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
|
||||
create_table :automatic_geocodings do
|
||||
primary_key :id
|
||||
Integer :table_id
|
||||
Text :state
|
||||
DateTime :run_at
|
||||
DateTime :created_at, null: false
|
||||
DateTime :updated_at, null: false
|
||||
Integer :interval
|
||||
Integer :retried_times
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table :automatic_geocodings
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :geocodings, :table_id, :integer
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :geocodings, :table_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :automatic_geocodings, :original_geocoding_id, :integer
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :geocodings, :original_geocoding_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
drop_column :automatic_geocodings, :original_geocoding_id
|
||||
add_column :geocodings, :automatic_geocoding_id, :integer
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :geocodings, :automatic_geocoding_id
|
||||
add_column :automatic_geocodings, :original_geocoding_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
drop_column :automatic_geocodings, :run_at
|
||||
drop_column :automatic_geocodings, :interval
|
||||
add_column :automatic_geocodings, :ran_at, DateTime
|
||||
end
|
||||
|
||||
down do
|
||||
add_column :automatic_geocodings, :run_at, DateTime
|
||||
add_column :automatic_geocodings, :interval, :integer
|
||||
drop_column :automatic_geocodings, :ran_at
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
SequelRails::connection.run 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'
|
||||
|
||||
create_table :organizations do
|
||||
Uuid :id, primary_key: true, null: false, unique: false, default: Sequel.lit('uuid_generate_v4()')
|
||||
Integer :seats
|
||||
Integer :quota_in_bytes
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table :organizations
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :users, :organization_id, :uuid
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :users, :organization_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :users, :organization_owner, :boolean, default: false
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :users, :organization_owner
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
set_column_type :organizations, :quota_in_bytes, :bigint
|
||||
end
|
||||
|
||||
down do
|
||||
set_column_type :organizations, :quota_in_bytes, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :organizations, :name, String
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :organizations, :name
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :created_at, DateTime, default: Sequel.function(:now)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
alter_table :users do
|
||||
add_column :updated_at, DateTime, default: Sequel.function(:now)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :geocodings, :cache_hits, :integer, default: 0
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :geocodings, :cache_hits, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
add_column :visualizations, :encrypted_password, String
|
||||
add_column :visualizations, :password_salt, String
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column :visualizations, :encrypted_password
|
||||
drop_column :visualizations, :password_salt
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user