mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Stock Exchanges with seed (#1351)
* Stock Exchanges with seed * Run the seed file on migration * Fix for enum column
This commit is contained in:
parent
d3a6f7e0f0
commit
73e184ad3d
7 changed files with 1126 additions and 1 deletions
30
db/migrate/20241022170439_create_stock_exchanges.rb
Normal file
30
db/migrate/20241022170439_create_stock_exchanges.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
class CreateStockExchanges < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :stock_exchanges, id: :uuid do |t|
|
||||
t.string :name, null: false
|
||||
t.string :acronym
|
||||
t.string :mic, null: false
|
||||
t.string :country, null: false
|
||||
t.string :country_code, null: false
|
||||
t.string :city, null: false
|
||||
t.string :website
|
||||
t.string :timezone_name, null: false
|
||||
t.string :timezone_abbr, null: false
|
||||
t.string :timezone_abbr_dst
|
||||
t.string :currency_code, null: false
|
||||
t.string :currency_symbol, null: false
|
||||
t.string :currency_name, null: false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :stock_exchanges, :country
|
||||
add_index :stock_exchanges, :country_code
|
||||
add_index :stock_exchanges, :currency_code
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
load Rails.root.join('db/seeds/exchanges.rb')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
db/migrate/20241022192319_fix_user_role_column_type.rb
Normal file
16
db/migrate/20241022192319_fix_user_role_column_type.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class FixUserRoleColumnType < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
# First remove any constraints/references to the enum
|
||||
execute <<-SQL
|
||||
ALTER TABLE users ALTER COLUMN role TYPE varchar USING role::text;
|
||||
SQL
|
||||
|
||||
# Then set the default
|
||||
change_column_default :users, :role, 'member'
|
||||
|
||||
# Finally drop the enum type
|
||||
execute <<-SQL
|
||||
DROP TYPE IF EXISTS user_role;
|
||||
SQL
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue