feat(migrate): add AddRememberTokenToUsers, down and CreateLoginSessions
This commit is contained in:
1 parent
56b040c2ad
commit
d9f5a673e3
12 files changed
+116
No files matched your search
@@ -0,0 +1,9 @@
|
||||
class AddRememberTokenToUsers < Prism::Orm::Migration
|
||||
def up
|
||||
add_column :users, :remember_token, default: nil
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :users, :remember_token
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class CreateLoginSessions < Prism::Orm::Migration
|
||||
def up
|
||||
create_table :login_sessions do |t|
|
||||
t.integer :user_id
|
||||
t.string :token
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :login_sessions
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class RemoveRememberTokenFromUsers < Prism::Orm::Migration
|
||||
def up
|
||||
remove_column :users, :remember_token
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :users, :remember_token, default: nil
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddUserAgentAndIpToLoginSessions < Prism::Orm::Migration
|
||||
def up
|
||||
add_column :login_sessions, :user_agent, default: nil
|
||||
add_column :login_sessions, :ip_address, default: nil
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :login_sessions, :user_agent
|
||||
remove_column :login_sessions, :ip_address
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddLikesCountToPostsAndComments < Prism::Orm::Migration
|
||||
def up
|
||||
add_column :posts, :likes_count, :integer, default: 0
|
||||
add_column :comments, :likes_count, :integer, default: 0
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :posts, :likes_count
|
||||
remove_column :comments, :likes_count
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnUsersEmail < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :users, :email, unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :users, :email
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnPostsStatus < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :posts, :status
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :posts, :status
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnPostsCreatedAt < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :posts, :created_at
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :posts, :created_at
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnCommentsPostId < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :comments, :post_id
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :comments, :post_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnLikesLikeable < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :likes, %i[likeable_id likeable_type]
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :likes, %i[likeable_id likeable_type]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnLoginSessionsUserId < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :login_sessions, :user_id
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :login_sessions, :user_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddIndexOnCommentsUserId < Prism::Orm::Migration
|
||||
def up
|
||||
add_index :comments, :user_id
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :comments, :user_id
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user