Skip to content

Commit

Permalink
add db:migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
andyduong1920 committed Apr 6, 2023
1 parent 436bbce commit 8d1f1ae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"key": "ctrl+f",
"command": "barHelper.formatCodeFile",
"when": "editorTextFocus"
},
{
"key": "ctrl+m",
"command": "barHelper.runDBMigrate"
}
],
"commands": [
Expand All @@ -83,6 +87,10 @@
"command": "barHelper.runDBRemigrate",
"title": "11111: ⭕ db:remigrate ⭕"
},
{
"command": "barHelper.runDBMigrate",
"title": "11111: ⬆️ db:migrate ⬆️"
},
{
"command": "barHelper.runDBSeed",
"title": "11111: 🌱 db:seed 🌱"
Expand Down
26 changes: 22 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ const formatCodeFileItem = window.createStatusBarItem(
StatusBarAlignment.Left,
-3
);
const runDBMigrateItem = window.createStatusBarItem(StatusBarAlignment.Left, -4);
const runDBSeedItem = window.createStatusBarItem(StatusBarAlignment.Left, -5);
const runDBRemigrateItem = window.createStatusBarItem(
StatusBarAlignment.Left,
-4
-6
);
const runDBSeedItem = window.createStatusBarItem(StatusBarAlignment.Left, -5);
const startInteractiveConsoleItem = window.createStatusBarItem(
StatusBarAlignment.Left,
-6
-7
);
const startWebServerItem = window.createStatusBarItem(
StatusBarAlignment.Left,
-7
-8
);

// Adjust here to add more items
const TEST_ITEMS = [runTestFileItem, runTestLineItem];
const BAR_ITEMS = [
runDBRemigrateItem,
runDBMigrateItem,
runDBSeedItem,
startInteractiveConsoleItem,
startWebServerItem,
Expand Down Expand Up @@ -169,9 +171,16 @@ export function activate(context: ExtensionContext) {
"Click to format the current file.",
"barHelper.formatCodeFile"
);
setupItem(
runDBMigrateItem,
"⬆️ db:MIGRATE (⌃m)",
"Click to run the db:migrate.",
"barHelper.runDBMigrate"
);

showItems([
runDBRemigrateItem,
runDBMigrateItem,
runDBSeedItem,
startInteractiveConsoleItem,
startWebServerItem,
Expand Down Expand Up @@ -226,6 +235,14 @@ export function activate(context: ExtensionContext) {
}
);

const runDBMigrateCommand = commands.registerCommand(
"barHelper.runDBMigrate",
() => {
// TODO: Support Elixir
sendToTerminal("bundle exec rails db:migrate");
}
);

const runDBSeedCommand = commands.registerCommand(
"barHelper.runDBSeed",
() => {
Expand Down Expand Up @@ -283,6 +300,7 @@ export function activate(context: ExtensionContext) {
runTestFileCommand,
runTestLineCommand,
runDBRemigrateCommand,
runDBMigrateCommand,
runDBSeedCommand,
startInteractiveConsoleCommand,
startWebServerCommand,
Expand Down

0 comments on commit 8d1f1ae

Please sign in to comment.